To fully align with ISO-8601, use yyyy-MM-dd'T'HH:mm:ss.SSSXXX as the default logging date format

See original GitHub issue

At present the default logging pattern does not append any timezone / offset information to the time of the event. This makes it impossible to parse back into an instant reliably (e.g. when using a log exporter to push a docker container’s stdout to elasticsearch or similar), because the timezone will be system / system property dependent.

Should just be a matter of adding XXX to the end of the default for LOG_DATEFORMAT_PATTERN in org/springframework/boot/logging/logback/defaults.xml & org.springframework.boot.logging.logback.DefaultLogbackConfiguration.

A good test is that the result is parseable by ZonedDateTime.parse. See DateConverterSpec which shows only XXX reliably produces a parseable ISO 8601 string.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
wilkinsonacommented, Apr 27, 2022

We’ve discussed this today and we’re going to add the T. We’ll make the changes for both Logback and Log4j2.

0reactions
michael-ocommented, Apr 26, 2022

@wilkinsona Yes, please do so. ISO 8601 clearly says (if you have access to the document): the ‘T’ can be replaced with a space only if a mutual agreement has been done between parties.

Same mistake was done in Git and they have ‘corrected’ with iso-strict.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Converting ISO 8601-compliant String to java.util.Date
I found the pattern yyyy-MM-dd'T'HH:mm:ssZ to be ISO8601-compliant if used with a Locale (compare sample). However, using the java.text.SimpleDateFormat , I ...
Read more >
PatternLayout does not really respect ISO8601 for date time
Using the default "%d" "%date" or %d. {ISO8601}. does not output a correct ISO 8601 formatted date and time representation.
Read more >
DateTimeFormat.ISO (Spring Framework 6.0.2 API)
The most common ISO Date Time Format yyyy-MM-dd'T'HH:mm:ss.SSSXXX — for example, "2000-10-31T01:30:00.000-05:00". NONE. Indicates that no ISO-based format ...
Read more >
FixedDateFormat.FixedFormat (Apache Log4j Core 2.19.0 API)
Returns the FastDateFormat object for formatting the date part of the pattern or null if the pattern does not have a date part....
Read more >
SimpleDateFormat (Java Platform SE 8 ) - Oracle Help Center
Each of these class methods can return a date/time formatter initialized with a default format pattern. You may modify the format pattern using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found