Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mahoney opened this issue Nov 12, 2021 · 9 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@Mahoney
Copy link

Mahoney commented Nov 12, 2021

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 12, 2021
@michael-o
Copy link

No timezones, offsets only. One should not use Z, but XXX only.

@wilkinsona wilkinsona added for: team-meeting An issue we'd like to discuss as a team to make progress type: enhancement A general enhancement labels Nov 15, 2021
@wilkinsona
Copy link
Member

wilkinsona commented Nov 15, 2021

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.

@michael-o
Copy link

@wilkinsona , please use XXX only. Z is RFC and should be burried. Please read MSHARED-837 how to make it truly extended ISO 8601.

@michael-o
Copy link

@Mahoney Please change the issue title accordingly.

@Mahoney Mahoney changed the title Include timezone in default logging pattern Include offset in default logging pattern Nov 15, 2021
@Mahoney
Copy link
Author

Mahoney commented Nov 15, 2021

@michael-o
Copy link

OK, I'm sold on XXX - see https://gist.github.com/Mahoney/9cd8ec0a0e72300aae8b4a16c95222d0

Told you ;-)

@philwebb philwebb added this to the 3.0.x milestone Nov 24, 2021
@philwebb philwebb removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Nov 24, 2021
@wilkinsona
Copy link
Member

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

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Apr 26, 2022
@michael-o
Copy link

michael-o commented 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.

@wilkinsona
Copy link
Member

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

@wilkinsona wilkinsona removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Apr 27, 2022
@wilkinsona wilkinsona changed the title Include offset in default logging pattern To fully align with ISO-8601, use yyyy-MM-dd'T'HH:mm:ss.SSSXXX as the default logging date format Apr 28, 2022
@scottfrederick scottfrederick self-assigned this May 3, 2022
@scottfrederick scottfrederick modified the milestones: 3.0.x, 3.0.0-M3 May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

6 participants