You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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 PHPcore/bootstrap.php
before setting it to 'UTC' and give that stored timezone to Monolog during initialization.The text was updated successfully, but these errors were encountered: