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

Timezone in application log is always "UTC" #11888

Closed
patrickbr opened this issue Jul 23, 2017 · 1 comment
Closed

Timezone in application log is always "UTC" #11888

patrickbr opened this issue Jul 23, 2017 · 1 comment
Labels
wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.

Comments

@patrickbr
Copy link
Contributor

patrickbr commented Jul 23, 2017

Piwik sets the PHP timezone to "UTC" by default (see here), overwriting the machines real timezone and the one that is configured in PHP.ini. While you may have good reasons to do this, one nasty side-effect is that the timestamps in the log file are also in UTC and not in the machine's timezone. This causes significant problems if the logfile is read by other applications (for example, fail2ban with this plugin). It is also just plain confusing, looks a bit unprofessional and makes it hard to harmonize logs.

The reason for this behavior is of course that Monolog uses date_default_timezone_get() to get the timezone it writes the logs in (see here).

This problem could be very easily fixed by using the setTimezone(DateTimeZone $tz) method provided by the Monolog logger. An approach could be: store the timezone configured in PHP core/bootstrap.php before setting it to 'UTC' and give that stored timezone to Monolog during initialization.

@mattab
Copy link
Member

mattab commented Jul 24, 2017

Thanks for the suggestion, I understand your point of view, but we log times in UTC by design because it is actually a best practise (at least for some of us). Once you have worked with servers all over the world in all different timezones, and you need to communicate to people in different timezones about servers in other timezones, It's not confusing to have times in UTC. It makes life much easier in the end.

@mattab mattab closed this as completed Jul 24, 2017
@mattab mattab added the wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it. label Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

2 participants