Log4j 2
  1. Log4j 2
  2. LOG4J2-319

Double stack trace logging when using %throwable in %style and %highlight

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta8
    • Fix Version/s: None
    • Component/s: Layouts
    • Labels:
      None
    • Environment:

      Description

      I'm seeing something odd in trunk:

      When I run org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain

      I see double stack traces:

      [30m2013-07-07 02:27:09,904 [m [34m[main] [m [33mFATAL: [m [32mFatal message.
      [m [30m2013-07-07 02:27:09,906 [m [34m[main] [m [33mERROR: [m [32mError message.
      [m [30m2013-07-07 02:27:09,907 [m [34m[main] [m [33mWARN : [m [32mWarning message.
      [m [30m2013-07-07 02:27:09,907 [m [34m[main] [m [33mINFO : [m [32mInformation message.
      [m [30m2013-07-07 02:27:09,907 [m [34m[main] [m [33mDEBUG: [m [32mDebug message.
      [m [30m2013-07-07 02:27:09,907 [m [34m[main] [m [33mTRACE: [m [32mTrace message.
      [m [30m2013-07-07 02:27:09,907 [m [34m[main] [m [33mERROR: [m [32mError message.
      java.io.IOException: test
      at org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain.main(ConsoleAppenderAnsiStyleLayoutMain.java:44)
      [m java.io.IOException: test
      at org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain.main(ConsoleAppenderAnsiStyleLayoutMain.java:44) [test-classes/:?]

      Note that the last one includes jar provenance.

      The patter in /log4j-core/src/test/resources/log4j2-console-style-ansi.xml is:

      %style{%d{ISO8601}}

      {black}

      %style

      {[%t]} {blue}

      %style

      {%-5level:} {yellow}

      %style

      {%msg%n%throwable} {green}

      When I switch the test to use

      /log4j-core/src/test/resources/log4j2-console.xml, the output contains a single track trace without jar provenance. The patter there is:

      %d

      {ISO8601}

      [%t] %-5level: %msg%n%throwable

      Looks like a bug in pattern/layout parsing?

      1. LOG4J2-319.diff
        4 kB
        Gary Gregory

        Issue Links

          Activity

          Hide
          Gary Gregory added a comment -

          The real bug is that when using %style, the pattern parser in the config does not know that exceptions may be used in the style pattern. Since it does not know, the parser adds exception logging (based on the alwaysWriteExceptions). The attached patch fixes that.

          Show
          Gary Gregory added a comment - The real bug is that when using %style, the pattern parser in the config does not know that exceptions may be used in the style pattern. Since it does not know, the parser adds exception logging (based on the alwaysWriteExceptions). The attached patch fixes that.
          Hide
          Gary Gregory added a comment -
          commit -m "[LOG4J2-319] Double stack trace logging when using %throwable in a %style." C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java C:/vcs/svn/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
              Sending        C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java
              Sending        C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java
              Sending        C:/vcs/svn/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
              Sending        C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml
              Sending        C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml
              Transmitting file data ...
              Committed revision 1516697.
          
          Show
          Gary Gregory added a comment - commit -m "[LOG4J2-319] Double stack trace logging when using %throwable in a %style." C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java C:/vcs/svn/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java Sending C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java Sending C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java Sending C:/vcs/svn/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java Sending C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml Sending C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml Transmitting file data ... Committed revision 1516697.
          Hide
          Gary Gregory added a comment -

          Reopening and fixing: Same problem for %highlight

          Show
          Gary Gregory added a comment - Reopening and fixing: Same problem for %highlight
          Hide
          Gary Gregory added a comment -
          commit -m "[LOG4J2-319] Double stack trace logging when using %throwable in %style and %highlight." C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/resources/log4j2-319.xml C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleJira319Main.java
              Sending        C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java
              Adding         C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleJira319Main.java
              Adding         C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/resources/log4j2-319.xml
              Transmitting file data ...
              Committed revision 1521180.
          
          Show
          Gary Gregory added a comment - commit -m "[LOG4J2-319] Double stack trace logging when using %throwable in %style and %highlight." C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/resources/log4j2-319.xml C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleJira319Main.java Sending C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java Adding C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleJira319Main.java Adding C:/vcs/svn/apache/log4j2/trunk/log4j-core/src/test/resources/log4j2-319.xml Transmitting file data ... Committed revision 1521180.

            People

            • Assignee:
              Gary Gregory
              Reporter:
              Gary Gregory
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development