Skip to content
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

Change date formats in logging to use RFC3339 #434

Open
wants to merge 2 commits into
base: mainline
Choose a base branch
from

Conversation

dBotLFG
Copy link

@dBotLFG dBotLFG commented Mar 18, 2022

Issue #, if available:

Description of changes:
Change date formats in logging to use UTC

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jkroepke
Copy link
Contributor

jkroepke commented Apr 7, 2022

Hi @dBotLFG,

what the reason to do this? Is it not enough to set the system time to UTC?

@dBotLFG
Copy link
Author

dBotLFG commented Apr 7, 2022

If the system time is set to local, the logs will use local time, but the timestamp will not reflect that it is local time (no offset indicator). By using a UTC timestamp by default, there will be no ambiguity in the time of the logged event. At a minimum, there should be a timezone offset used by default. As the code currently stands, it would be very difficult to correlate events between instances located in different regions with different timezones. Thank you for your consideration.

@jkroepke
Copy link
Contributor

jkroepke commented Apr 7, 2022

If the system time is set to local, the logs will use local time,

In a default configuration, I always expect this. Each system component is logging in localtime. Use UTC by default would confuse a lot of people here. For example current logs from journalctl:

Apr 07 15:19:58 i-0b1615f6a27caa92f amazon-ssm-agent[372718]: 2022-04-07 15:19:57 INFO [amazon-ssm-agent] [LongRunningWorkerContainer] Monitor long running worker health every 60 seconds

In case, logs are UTC

Apr 07 15:19:58 i-0b1615f6a27caa92f amazon-ssm-agent[372718]: 2022-04-07 13:19:57 INFO [amazon-ssm-agent] [LongRunningWorkerContainer] Monitor long running worker health every 60 seconds

or in winter time

Apr 07 15:19:58 i-0b1615f6a27caa92f amazon-ssm-agent[372718]: 2022-04-07 14:19:57 INFO [amazon-ssm-agent] [LongRunningWorkerContainer] Monitor long running worker health every 60 seconds

Having different times on a single line looks very odd.

I agree with you. UTC is removes a lot trouble, for example daylight saving time and helps if operations is done in multiple timezones. In conclusion, the system time should be also UTC. Consider to set CRON_TZ to local time, if cronjobs on the system should be run in a localtime.

but the timestamp will not reflect that it is local time (no offset indicator)

From my point of view, this is the real issue here. Using RFC3339 ("2006-01-02T15:04:05Z07:00") should solve this.

@dBotLFG dBotLFG changed the title Change date formats in logging to use UTC Change date formats in logging to use RFC3339 Apr 8, 2022
@dBotLFG
Copy link
Author

dBotLFG commented Apr 8, 2022

Agreed, switched to RFC3339

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.

2 participants