You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2023/04/13 18:55:52 UTC

[I] StackOverflowException in Logger.isEnabled with Spring Boot 3 + Tomcat (logging-log4j2)

ppkarwasz opened a new issue, #1430:
URL: https://github.com/apache/logging-log4j2/issues/1430

   ## Description
   
   Tomcat calls `Logger.isEnabled` at the beginning of its `ClassLoader#loadClass` implementation.
   
   If the method requires to load additional classes (e.g. `org.apache.logging.log4j.core.Filter.Result`) an infinite recursion occurs.
   
   ## Reproduction
   
    * configure Tomcat to use Log4j 2.x as server's logging framework,
    * add a Spring Boot 3 application **without** Log4j2 jars,
    * a stack overflow occurs.
   
   ## Details
   
   This issue was first reported in [this StackOverflow question](https://stackoverflow.com/q/75667479/11748454).
   
   The problem occurs because:
   
   1. If no logger context exists for a given classloader and `configLocation == null` the `ClassLoaderContextSelector` returns the logger context for the parent classloader. This is what happens in most `LogManager.getContext` calls;
   2. Spring Boot adds a class from the webapp classloader as global filter to the logger context's configuration;
   3. Tomcat calls `Logger.isEnabled` at the beginning of `ClassLoader#loadClass` hence it triggers the loading of all classes used by the global filter. This process uses the webapp classloader, hence the recursion.
   


-- 
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: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] StackOverflowException in Logger.isEnabled with Spring Boot 3 + Tomcat (logging-log4j2)

Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on issue #1430:
URL: https://github.com/apache/logging-log4j2/issues/1430#issuecomment-1507762189

   I think this problem is more general than you are making it out to be. Anytime there is a sequence of 
   app-> jul -> log4j -> 3rd party -> jul
   there will be an infinite loop. We need to prevent that by detecting recursion in ApiLogger.


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] StackOverflowException in Logger.isEnabled with Spring Boot 3 + Tomcat (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1430:
URL: https://github.com/apache/logging-log4j2/issues/1430#issuecomment-2066692174

   I am closing this, since it was fixed in Spring Boot 3.1.11 and 3.2.5.


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] StackOverflowException in Logger.isEnabled with Spring Boot 3 + Tomcat (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #1430: StackOverflowException in Logger.isEnabled with Spring Boot 3 + Tomcat
URL: https://github.com/apache/logging-log4j2/issues/1430


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org