[ https://issues.apache.org/jira/browse/LOG4J2-1793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15829617#comment-15829617 ]
Remko Popma edited comment on LOG4J2-1793 at 1/19/17 9:48 AM: -------------------------------------------------------------- Looking at your screenshot, the exception has itself as the cause: {code} thrown= {ArithmeticException@2101} "java.lang.ArithmeticException: / by zero" cause= {ArithmeticException@2101} "java.lang.ArithmeticException: / by zero" <- exception has itself as the cause... cause= {ArithmeticException@2101} "java.lang.ArithmeticException: / by zero" ... {code} So the cause of the exception is the exception itself. This is a circular reference. When logging such an exception you need to take special care to prevent getting caught in an eternal loop. For example, the JDK {{[java.lang.Throwable|http://www.docjar.com/html/api/java/lang/Throwable.java.htm]}} (line 645-710) uses an IdentityHashSet to prevent an eternal loop. Similarly, Log4j's {{[ThrowableProxy|https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java#L131]}} uses a HashSet to track previously visited {{cause}} exceptions to prevent an eternal loop. was (Author: rem...@yahoo.com): Looking at your screenshot, the exception has itself as the cause: {code} thrown= {ArithmeticException@2101} "java.lang.ArithmeticException: / by zero" cause= {ArithmeticException@2101} "java.lang.ArithmeticException: / by zero" cause= {ArithmeticException@2101} "java.lang.ArithmeticException: / by zero" ... {code} So the cause of the exception is the exception itself. This is a circular reference. When logging such an exception you need to take special care to prevent getting caught in an eternal loop. For example, the JDK {{[java.lang.Throwable|http://www.docjar.com/html/api/java/lang/Throwable.java.htm]}} (line 645-710) uses an IdentityHashSet to prevent an eternal loop. Similarly, Log4j's {{[ThrowableProxy|https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java#L131]}} uses a HashSet to track previously visited {{cause}} exceptions to prevent an eternal loop. > Why there can't get thrown from LogEvent > ---------------------------------------- > > Key: LOG4J2-1793 > URL: https://issues.apache.org/jira/browse/LOG4J2-1793 > Project: Log4j 2 > Issue Type: Bug > Components: Core > Affects Versions: 2.7 > Environment: JDK1.8, CentOS6 > Reporter: elkan > Labels: patch > Original Estimate: 48h > Remaining Estimate: 48h > > There I want create a customer defined appender and need get stack case > message. So in over write append method when implements AbstractAppender, > then use the function like below code: > logEvent.getThrown().getCause() > http://77l54p.com1.z0.glb.clouddn.com/qq20170119142117-log4j2-debug.png-alias > (Debug Info) > But it very interesting, it out put null, but I use Eclipse debug enter it > can get message and seems it were drop-dead halt. Is it a bug problem. There > need you help, thanks. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org