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

Better handling of %highlight pattern when using jul-bridge

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      When using the jul-bridge and %highlight in the pattern layout, LogLevels that are not mapped to log4j LogLevels incorrectly display "null" in front of the highlighted string.

      See the following pattern:

      {{pattern="%d %highlight

      {%-6p} [%c{1.}] (%t) %m%n"}}

      that should display the loglevel with color highlighting.

      The following log statements:

      {{
      LOGGER.log(Level.SEVERE, "SEVERE");
      LOGGER.log(Level.WARNING,"WARN");
      LOGGER.log(Level.INFO, "INFO");
      LOGGER.log(Level.FINE, "FINE");
      LOGGER.log(Level.FINER, "FINER");
      LOGGER.log(Level.FINEST, "FINEST");
      LOGGER.log(Level.CONFIG, "CONFIG");
      }}

      will be displayed as in the attached picture.

      As you can see the FINEST and CONFIG levels are not highlighted (which is acceptable), but are prefixed by "null", which is not acceptable.

      I think it would be well enough to support setting the style for such unknown log levels like:

      {{pattern="%d %highlight{%-6p} {FINEST=black, CONFIG=blue}

      [%c

      {1.}

      ] (%t) %m%n"}}

      This would also allow to set a color different than black for these log levels.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            hupfdule Marco Herrn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment