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.
Comment From: michael-o
No timezones, offsets only. One should not use Z, but XXX only.
Comment From: wilkinsona
As I understand it, Z will produce an offset. It is z that will not. That said, given our preference for ISO-8601 elsewhere, if we decide to do this I think it makes sense to use XX or XXX rather than Z. I agree that z should be avoided.
Flagging for team meeting so that we can discuss whether we want to make this change, and if we do, the timing of it. It feels like something that should possibly wait until 3.x to me.
Comment From: michael-o
@wilkinsona , please use XXX only. Z is RFC and should be burried. Please read MSHARED-837 how to make it truly extended ISO 8601.
Comment From: michael-o
@Mahoney Please change the issue title accordingly.
Comment From: Mahoney
OK, I'm sold on XXX - see https://gist.github.com/Mahoney/9cd8ec0a0e72300aae8b4a16c95222d0
Comment From: michael-o
OK, I'm sold on
XXX- see https://gist.github.com/Mahoney/9cd8ec0a0e72300aae8b4a16c95222d0
Told you ;-)
Comment From: wilkinsona
If we're going to add an offset, I wonder if we should go one step further and also use the T separator rather than a space. That would fully align with ISO-8601.
Our current format produces timestamps like the following:
2022-04-26 11:12:51.001
Adding an offset would change this to the following:
2022-04-26 11:12:51.001+01:00
Fully aligning with ISO-8601 would change this to the following:
2022-04-26T11:12:51.001+01:00
Comment From: michael-o
@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.
Comment From: wilkinsona
We've discussed this today and we're going to add the T. We'll make the changes for both Logback and Log4j2.