Uploaded image for project: 'Hippo Configuration Management'
  1. Hippo Configuration Management
  2. HCM-192

Log4j2 fails if cms-commons is included in Maven shaded uberjar: ERROR StatusLogger Unrecognized format specifier

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.1
    • Labels:
      None
    • Similar issues:
    • Processed by team:
      Turing
    • Sprint:
      Turing Sprint 163

      Description

      cms-commons contains the LookupFilter log4j2 plugin. For this a Log4j2Plugins.dat [1] cache file is included in the cms-commons jar.

      When the Maven shade plugin is used to merge multple jars with such a Log4j2Plugins.dat file only one will survive.

      See [3] for more information. 

      Without the plugin definitions errors are shown on startup:

      ERROR StatusLogger Unrecognized format specifier [d]
      ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
      ERROR StatusLogger Unrecognized format specifier [thread]
      ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.

      Possible solutions

      1. Exclude all plugin cache files from the uberjar. Log4j will scan for plugins on startup. This will slow down the startup
      2. Exclude the cache file from cms-commons and don't use that filter in the log4j configuration
      3. Merge the cache files using a Maven transformation plugin [2]. Drawback is that this is log4j-version specific, currently using log4j 2.8.1

       

      [1] META-INF/org/apache/logging\log4j/core/config/plugins/Log4j2Plugins.dat

      [2] https://github.com/edwgiz/maven-shaded-log4j-transformer

      [3] https://issues.apache.org/jira/browse/LOG4J2-673

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              abanck Arent-Jan Banck
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: