You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2019/04/11 13:23:47 UTC

StackOverflowError at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)

Have you guys seen this one and is there a way we can guard against it.

java.lang.StackOverflowError
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at
org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at
org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at
org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at
org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at
org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at
org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
...

Thank you,
Gary

Re: StackOverflowError at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Apr 11, 2019 at 11:34 AM Ralph Goers <ra...@dslextreme.com>
wrote:

> That should be doable. We can set a ThreadLocal that indicates one of the
> APIs was called and check for it in the other and throw an Exception if it
> is found. Create a Jira issue.
>

Voila: https://issues.apache.org/jira/browse/LOG4J2-2597

Gary


>
> Ralph
>
> > On Apr 11, 2019, at 8:09 AM, Matt Sicker <bo...@gmail.com> wrote:
> >
> > Yup, too many bridges on the classpath caused an infinite loop. If we
> > had a recursion detector similar to AppenderControl (IIRC), that might
> > help.
> >
> > On Thu, 11 Apr 2019 at 08:38, Carter Kozak <ck...@ckozak.net> wrote:
> >>
> >> Yep, that looks like the failure scenario we've highlighted in red in
> the docs.
> >> https://logging.apache.org/log4j/2.x/log4j-to-slf4j/index.html
> >>
> >> I'm not sure how we would guard against it, arguably failing silently
> (not logging) in this case would be worse than throwing.
> >>
> >> On Thu, Apr 11, 2019, at 09:24, Gary Gregory wrote:
> >>> Have you guys seen this one and is there a way we can guard against it.
> >>>
> >>> java.lang.StackOverflowError
> >>> at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
> >>> at
> >>>
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
> >>> at
> >>>
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> >>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> >>> at
> >>>
> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
> >>> at
> >>>
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> >>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> >>> at
> >>>
> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
> >>> at
> >>>
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
> >>> at
> >>>
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
> >>> ...
> >>>
> >>> Thank you,
> >>> Gary
> >>>
> >
> >
> >
> > --
> > Matt Sicker <bo...@gmail.com>
> >
>
>
>

Re: StackOverflowError at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)

Posted by Ralph Goers <ra...@dslextreme.com>.
That should be doable. We can set a ThreadLocal that indicates one of the APIs was called and check for it in the other and throw an Exception if it is found. Create a Jira issue.

Ralph

> On Apr 11, 2019, at 8:09 AM, Matt Sicker <bo...@gmail.com> wrote:
> 
> Yup, too many bridges on the classpath caused an infinite loop. If we
> had a recursion detector similar to AppenderControl (IIRC), that might
> help.
> 
> On Thu, 11 Apr 2019 at 08:38, Carter Kozak <ck...@ckozak.net> wrote:
>> 
>> Yep, that looks like the failure scenario we've highlighted in red in the docs.
>> https://logging.apache.org/log4j/2.x/log4j-to-slf4j/index.html
>> 
>> I'm not sure how we would guard against it, arguably failing silently (not logging) in this case would be worse than throwing.
>> 
>> On Thu, Apr 11, 2019, at 09:24, Gary Gregory wrote:
>>> Have you guys seen this one and is there a way we can guard against it.
>>> 
>>> java.lang.StackOverflowError
>>> at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
>>> at
>>> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
>>> at
>>> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
>>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
>>> at
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
>>> at
>>> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
>>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
>>> at
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
>>> at
>>> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
>>> at
>>> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
>>> ...
>>> 
>>> Thank you,
>>> Gary
>>> 
> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>
> 



Re: StackOverflowError at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)

Posted by Matt Sicker <bo...@gmail.com>.
Yup, too many bridges on the classpath caused an infinite loop. If we
had a recursion detector similar to AppenderControl (IIRC), that might
help.

On Thu, 11 Apr 2019 at 08:38, Carter Kozak <ck...@ckozak.net> wrote:
>
> Yep, that looks like the failure scenario we've highlighted in red in the docs.
> https://logging.apache.org/log4j/2.x/log4j-to-slf4j/index.html
>
> I'm not sure how we would guard against it, arguably failing silently (not logging) in this case would be worse than throwing.
>
> On Thu, Apr 11, 2019, at 09:24, Gary Gregory wrote:
> > Have you guys seen this one and is there a way we can guard against it.
> >
> > java.lang.StackOverflowError
> > at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
> > at
> > org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
> > at
> > org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> > at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> > at
> > org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
> > at
> > org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> > at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> > at
> > org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
> > at
> > org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
> > at
> > org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
> > ...
> >
> > Thank you,
> > Gary
> >



-- 
Matt Sicker <bo...@gmail.com>

Re: StackOverflowError at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)

Posted by Carter Kozak <ck...@ckozak.net>.
Yep, that looks like the failure scenario we've highlighted in red in the docs.
https://logging.apache.org/log4j/2.x/log4j-to-slf4j/index.html

I'm not sure how we would guard against it, arguably failing silently (not logging) in this case would be worse than throwing.

On Thu, Apr 11, 2019, at 09:24, Gary Gregory wrote:
> Have you guys seen this one and is there a way we can guard against it.
> 
> java.lang.StackOverflowError
> at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> at
> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> at
> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
> ...
> 
> Thank you,
> Gary
>