How to log the time in the UTC time format?
Maxim Dounin
mdounin at mdounin.ru
Tue Dec 1 02:29:31 MSK 2009
Hello!
On Mon, Nov 30, 2009 at 05:06:57PM -0500, naltimari wrote:
> Well, maybe you're right, but what I need is the same time that would come from 'date -u' command.
>
> Right now, my log time format is like this: 30/Nov/2009:16:14:39 -0200
It's date and time in common log format
(http://en.wikipedia.org/wiki/Common_Log_Format).
> When I need this: Mon Nov 30 18:14:39 UTC 2009
>
> Can I change the syntax/format in which the date is written to the log?
No, the is no way to specify arbitrary format for time. The only
available options out-of-the box is $time_local (time in common log
format) and $msec (seconds since the Epoch with milliseconds
resolution).
The only option for now is to use something like embedded perl to
construct time in arbitrary format, something like
perl_set $tt 'sub { scalar localtime }';
and then use it in logs via appropriate log_format. But I don't
really think it's a good way to go.
BTW, could you please explain why do you need time in this particular
format?
Maxim Dounin
More information about the nginx
mailing list