Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3156

Stacktraces with xEx conversion are expanded resulting in duplicate/redundant line in the trace

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Workaround
    • 2.14.1
    • None
    • Layouts
    • None

    Description

      I have an application that uses the log4j2(2.14.1) library for logging. In the application I use PatternLayout. The conversion patterns for the stackTraceElement seems a bit confusing to me. If I use the 'ex' conversion pattern for the stack traces I get the .... xx more view for nested exceptions. That is totally fine since I do not want to see duplicate things in the trace. In addition to this I would like to see the jar file name in each line of the stacktrace. 

      By looking at the documentation of PatternLayout( https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout ) I see that I can use xEx conversion. In the documentation it says 'The same as the %throwable conversion word but also includes class packaging information.' for the xEx conversion. However, when I use the xEx conversion in my pattern I see the '... xx more' collapsed views are expanded(e.g. ... 137 more becomes ... 6 more and prints the 131 lines) and display the same lines as the parent/child exception. This results in lots of duplicated and redundant lines in the stacktrace. 

      In the attachments you may see the differences of 'ex' and 'xEx' conversions for the same trace.

      Patterns I used:

      <Pattern>%d{yyyy-MM-dd HH:mm:ss,SSS} %5p [%t] %TC %c{2} - %m%ex%n</Pattern> <!-- condensed stacktrace with no library information -->

      <Pattern>%d{yyyy-MM-dd HH:mm:ss,SSS} %5p [%t] %TC %c{2} - %m%xEx%n</Pattern> <!-- with library information but no condensed stacktrace -->

      Is there a different way to keep the stacktrace showing ... xx more lines view in combination with the jar filename in each line in the trace?

      Attachments

        1. xEx.txt
          248 kB
          Ali Akcan
        2. ex.txt
          107 kB
          Ali Akcan

        Activity

          People

            Unassigned Unassigned
            Alisihab Ali Akcan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: