Rotating Access Logs with $date_local

Igal @ igal at
Tue Oct 28 16:48:32 UTC 2014

Hello Maxim,
> It is possible - you can use construct appropriate variable, e.g., 
> by using map{} and $time_local.  (The $date_local won't work for 
> you as you won't be able to set format without SSI.)
Thank you for your prompt reply.  I do not have much experience with
nginx configuration so I have a follow up question.

I looked up the docs about map{} at and I tried to
follow the example.  I see that $time_local is (in my local time)
"28/Oct/2014:09:30:35 -0700" so I want from that the year, month, and
day.  as an experimentation, I tried to add the following:

    map $time_local $date {
        ~\w{11}    0;

but I get an error that the '{' character is not valid at that
position.  so I tried instead

    ~\w\w\w\w\w\w\w\w\w\w\w    0;

and then nginx starts up but $date is an empty string.

Can you point me in the right direction?  and if it's not too
complicated make a suggestion regarding the regex that I would need
since I must break the $time_local to year, month, and day (or do I need
to create 3 map{} variables for that?  now that would be inefficient...)

> On the other hand, it's not recommended as it implies unneeded 
> work on each request. 
With the amount of traffic that I get, and the way that nginx is
handling it, these few added microseconds should not be an issue IMO and
it would be a much easier solution to implement than an external process
that may or may not work properly.

Thanks a lot!

Igal Sapir
Railo Core Developer

More information about the nginx mailing list