Details
-
Bug
-
Resolution: Unresolved
-
Major
-
1.3.0-beta0
-
None
Description
PatternLayout trims the event timestamp down to milliseconds precision irrespective of the configured pattern.
For instance the following config:
<appender name="LOGBACK" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%date{dd-MM-yyyy'T'HH:mm:ss.n} - %msg%n</pattern> </encoder> </appender>
produces output like the following:
13-08-2022T16:05:49.211000000 - A sample log message (0) 13-08-2022T16:05:49.213000000 - A sample log message (1) 13-08-2022T16:05:49.213000000 - A sample log message (2) 13-08-2022T16:05:49.213000000 - A sample log message (3) 13-08-2022T16:05:49.213000000 - A sample log message (4) 13-08-2022T16:05:49.213000000 - A sample log message (5)
As you can see although the pattern asks for nanoseconds after the seconds only the millis are actually output with the nano parts set to zero.
A quick look at the code reveals that the DateConverter gets the timestamp from the ILoggingEvent by calling ILoggingEvent#getTimeStamp() which gives the timestamp in millis instead of the new ILoggingEvent#getInstant().