jackshirazi commented on PR #2768: URL: https://github.com/apache/logging-log4j2/pull/2768#issuecomment-2250132082
We don't use LoaderUtil. The linked issue is [this](https://github.com/elastic/apm-agent-java/issues/3691). The full sequence is pretty convoluted 1. Elastic agent opens a url connection, java.net.URL.openConnection which loads sun.net.www.protocol.http.HttpURLConnection 2. HttpURLConnection inits it's logger, a jul logger 3. The command line set -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager so apache logger is used 4. Because this was loaded from the elastic agent, the current classloader is co.elastic.apm.agent.premain.ShadedClassLoader 5. ShadedClassLoader loads the log4j classes up to org.apache.logging.log4j.core.async.RingBufferLogEventHandler 6. The log4j2 class AsyncLoggerDisruptor casts the RingBufferLogEventHandler instance as a EventHandler, but EventHandler was loaded by log4j2 in the app classloader 7. hence the CCE Because this is a class loading race condition with the JVM classes using the log4j2 logger before the JVM is initialized (agent's kick in at premain), this is complex to solve outside of log4j2, whereas this patch is pretty simple -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
