Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1735

ILoggingEvent#getInstant should return `Instant.ofEpochMills(getTimeStamp())` instead of `null` as a better alternative

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 1.4.9, 1.3.9
    • 1.4.8
    • logback-classic
    • None

    Description

       

      `ILoggingEvent#getInstant()` is introduced in version 1.3.
      But, the default implementation returns null.
      I think this is the compatibility issue between 1.2.x ~ 1.3.x.
      I propose default implementation returns `Instant.ofEpochMills(getTimeStamp())` to improve compatibility with 1.2 or prior.

       

      In some cases, the compatibility breaks logging.

      Reproduction

      In my case, the compatibility is broken in the following conditions.

      • use logstash-logback-encoder 5.3
      • use armeria-logback 1.23.1
        • this module is compiled with logback 1.2.x
      • use logback 1.4.x
      • use this logback config

       

          <configuration>
              <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
                  <encoder class="net.logstash.logback.encoder.LogstashEncoder" />
              </appender>
              <appender name="RCEA" class="com.linecorp.armeria.common.logback.RequestContextExportingAppender">
                  <appender-ref ref="STDOUT" />
              </appender>
              <root level="info">
                  <appender-ref ref="RCEA" />
              </root>
          </configuration> 

       

      The logstash-logback-encoder 7.3 calls `getInstant()` when logback 1.3 or higher, here].
      But, armeria-logback has LoggingEventWrapper that extends logback's LoggingEvent.
      The LoggingEventWrapper lacks the implementation of `getInstant()` because it depends on logback 1.2 to keep compatibility.
      Therefore, logstash-logback-encoder are going to get `null` by default implementation of `getInstant` in ILoggingEvent.
      After that, logging is not working by NullPointerException.

       

       

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            wreulicke wreulicke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: