Unix Timestamp in Apache Combined Log

apache-2.2loggingtime

So basic question, but I can't seem to find an easy answer.

How do I record the date/time in my apache logs to have a unix timestamp (seconds since epoch).

I have the default LogFormat as:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined

Best Answer

Apache Module mod_log_config:

%{format}t  The time, in the form given by format, which should be in strftime(3) format. (potentially localized)

Example:

    LogFormat "%v %h %l %u %{%s}t \"%r\" %>s %b" vhost_common
    CustomLog /var/log/test vhost_common

Log:

127.0.1.1 127.0.0.1 - - 1309405372 "GET / HTTP/1.0" 200 177
Related Topic