Skip to content

Update iso timestamp to include timezone #17706

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ash-darin
Copy link

@ash-darin ash-darin commented Jun 11, 2025

enhancement

This changes the timestamp for log4j logging into a format, which includes the timezone. This will make it easier for all applications who read the logs to place it correctly without having to guess that this is UTC. Support for this format is documented here:

https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.FixedFormat.html

This should not break compatibility as the Format is still ISO8601 conforming.

This fixes: #10238

Release notes

Change timestamp in logging to include timezone. Fixes #10238

What does this PR do?

This changes the exposed timestamp in the logstash logs from an ISO timestamp without timezone information to a timestamp with timezone information.

Example:

[2025-06-11T12:14:57,812][INFO ][logstash.agent ] Pipelines running
`
becomes:

[2025-06-11T12:14:57,812+00:00][INFO ][logstash.agent ] Pipelines running
`

The format and setting is explained here:

https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.FixedFormat.html#ISO8601_OFFSET_DATE_TIME_HHCMM

Note: This is also the timestamp format that kibana uses:

[2025-06-11T15:51:07.413+00:00][INFO ][plugins.actions.server-log]`

Why is it important/What is the impact to the user?

This change allows programs that ingest the logs to correctly autodetect the timezone without having to just assume "UTC" as many programs assume local time without a timezone identifier, see also here:

If no UTC relation information is given with a time representation, the time is assumed to be in local time.

https://en.wikipedia.org/wiki/ISO_8601#Local_time_(unqualified)

Both the old and the new timestamp are ISO8601 format timestrings and all programms supporting ISO8601 parsing should read and interpret the new format automatically.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files (and/or docker env variables)
  • [-] I have added tests that prove my fix is effective or that my feature works

Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Contributor

mergify bot commented Jun 11, 2025

This pull request does not have a backport label. Could you fix it @ash-darin? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@ash-darin ash-darin changed the title Update iso timestamp Update iso timestamp to include timezone Jun 11, 2025
@ash-darin
Copy link
Author

This pull request does not have a backport label. Could you fix it @ash-darin? 🙏 To fixup this pull request, you need to add the backport labels for the needed branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

I'd love to but I am not authorized apparently. Yes, a backport to 8.x would be nice.

@ash-darin ash-darin marked this pull request as ready for review June 11, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include time zone in Logstash logs
1 participant