3

How to show timezone in the apache 2.4.25 ErrorLog. I have put the ErrorLogFormat in VirtualHost :

ErrorLogFormat "%{cu}t"

But than I only get 2018-02-08 10:02:59.246032. Which is the time in the +01:00 time in fact.

In LogFormat it is possible just by %{%Y-%m-%dT%H:%M:%S}t.%{msec_frac}t%{%z}t which gives 2018-02-08T10:07:46.161+0100. When I use the same in ErrorLogFormat I get Thu Feb 08 10:07:46 2018.2018-02-08 10:07:46Thu Feb 08 10:07:46 2018 instead.

Is there a way to show the correct timezone?

luki
  • 31
  • 2
  • you can see this my Dear good luck [enter link description here](https://serverfault.com/questions/26248/what-could-cause-apaches-time-timezone-to-change-intermittently) – total min Feb 08 '18 at 09:18
  • you could of course put the timezone as static text in the format. – wurtel Feb 08 '18 at 10:39

1 Answers1

2

It seems that it is not possible. With LogFormat it passes the format to strftime(3), but with ErrorLogFormat it does not.

If the timezone is important to your ErrorLog, you can consider to use Logstash / ELK-stack for parsing the logs and adding a timestamp to the log entry before it is indexed.

pkhamre
  • 5,900
  • 3
  • 15
  • 27
  • I plan to log the all the Errors as JSON, and than use [filebeat](https://www.elastic.co/guide/en/beats/filebeat/current/index.html) to send them out to redis db. Any idea how to process it such way with filebeat? – luki Feb 08 '18 at 14:11
  • 1
    Found a way to add a timezone to beat using [processors](https://www.elastic.co/guide/en/beats/filebeat/current/add-locale.html), but still the timezone can be wrong when using reading old files after the timezone change. So to have it always correct it should be done on the writing of the logs, not reading – luki Feb 08 '18 at 14:42