Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-23863

Switch logger backend to Log4j 2

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.3
    • Upgrade notes:
      Hide

      Nuxeo now uses Log4j 2 as its logging backend instead of Log4j.
      Two logging APIs are generally available in Nuxeo:

      • Commons Logging
      • Log4j 2 API

      SLF4J is still available, but Log4j 2 API are preferred by reason of its lambda support.

      Breaking change

      • Log4jHelper.setQuiet and Log4jHelper.setDebug was removed due to its usage of Log4j API which are now impossible with Log4j 2. These APIs were replaced by Log4jHelper.setLevel. Compared to previous implementation, setLevel API doesn't change appender's threshold, it just acts on logger's levels.
      • LogCaptureFeature.Filter has also changed without backward compatibility because it exposed a Log4j internal class. This has been replaced by corresponding Log4j 2 internal class.
      • File rollover has changed. Files are now compressed using gzip and pattern has been generalised to NAME-YYYY-MM-dd.log.gz. For instance:

        server.log.2018-01-01 becomes server-2018-01-01.log.gz

      • Watch log4j file for reload has been removed in favor of built-in logic in Log4j2.
        These properties are no longer read:
        • org.nuxeo.runtime.log4jwatch.disabled
        • org.nuxeo.runtime.log4jwatch.delay
          See Automatic Reconfiguration in Log4j 2 documentation to have watch file behavior.

      Code behavior change

      • LogCaptureFeature behavior has changed. Now log Result is cleaned between each tests. You'll have an isolated result to assert for @Before/@After/test methods.
      • You may need to add the slf4j dependency if you were using it in your source code:
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </dependency>
        

      New

      • LogCaptureFeature.FilterOn now accepts a logger class instead of a logger name
      • You can now use Log4j 2 API in your code
      Show
      Nuxeo now uses Log4j 2 as its logging backend instead of Log4j. Two logging APIs are generally available in Nuxeo: Commons Logging Log4j 2 API SLF4J is still available, but Log4j 2 API are preferred by reason of its lambda support. Breaking change Log4jHelper.setQuiet and Log4jHelper.setDebug was removed due to its usage of Log4j API which are now impossible with Log4j 2. These APIs were replaced by Log4jHelper.setLevel . Compared to previous implementation, setLevel API doesn't change appender's threshold, it just acts on logger's levels. LogCaptureFeature.Filter has also changed without backward compatibility because it exposed a Log4j internal class. This has been replaced by corresponding Log4j 2 internal class. File rollover has changed. Files are now compressed using gzip and pattern has been generalised to NAME-YYYY-MM-dd.log.gz . For instance: server.log.2018-01-01 becomes server-2018-01-01.log.gz Watch log4j file for reload has been removed in favor of built-in logic in Log4j2. These properties are no longer read: org.nuxeo.runtime.log4jwatch.disabled org.nuxeo.runtime.log4jwatch.delay See Automatic Reconfiguration in Log4j 2 documentation to have watch file behavior. Code behavior change LogCaptureFeature behavior has changed. Now log Result is cleaned between each tests. You'll have an isolated result to assert for @Before / @After /test methods. You may need to add the slf4j dependency if you were using it in your source code: <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> New LogCaptureFeature.FilterOn now accepts a logger class instead of a logger name You can now use Log4j 2 API in your code
    • Sprint:
      nxcore 10.3.6
    • Story Points:
      8

      Description

      Our current logger backend, Apache Log4j 1, is EOL since 2015. We should move to a more modern backend.

      Note that the logger front-end we use (Apache Commons Logging) is not being changed.

      Beyond maintenance, the current Log4j 1 is rather slow and doesn't have modern capabilities like Message Objects which make for shorter code (no need to call if (log.isDebugEnabled()) in most cases).

      Some background:

      So, upgrade log4j to log4j2, furthermore clean some logging codes, files etc...

      See linked migration file to see changements.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 day
                  1w 1d