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

style & highlight patterns altering content behaviour

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.0-beta4
    • None
    • Layouts
    • None

    Description

      • Using style or highlight patterns over a Throwable pattern makes this code useless if the exception is the only content (i.e. "%highlight {%ex}

        ")

        org.apache.logging.log4j.core.pattern.ThrowablePatternConverter:format(final LogEvent event, final StringBuilder toAppendTo) {
        ...
                    final int len = toAppendTo.length();
                    if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
                        toAppendTo.append(" "); // Add a space before printing stack trace
                    }
        ...
        }
        

        (With style or highlight patterns, the format is called with a new empty StringBuilder)

      Example:

      17:26:54.395 ERROR # Server.doOperation catchingjava.lang.NullPointerException
      

      (Syntax affected, no space between the message 'catching' and the exception 'java.lang.NullPointerException')

      • Using style or highlight patterns over a Throwable pattern makes it to be duplicated (the pattern is interpreted as if there was nothing dealing with throwables)

      Examples:

      Simple pattern: "%m %ex{short}"
      Output: catching java.lang.NullPointerException
              at net.wm.core.prototype.Server.doOperation(Server.java:27)
      
      Pattern with highlight: "%m %highlight{%ex{short}}"
      Output: catching java.lang.NullPointerException
              at net.wm.core.prototype.Server.doOperation(Server.java:27)
       java.lang.NullPointerException
              at net.wm.core.prototype.Server.doOperation(Server.java:27) [bin/:?]
              at net.wm.core.AbstractOperation.run(AbstractOperation.java:99) [bin/:?]
              at java.lang.Thread.run(Unknown Source) [?:1.7.0_07]
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              seyguai Seyguai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: