I've configured a site like this:
map $time_iso8601 $yyyy {
default '0000';
"~^(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})" $y;
}
map $time_iso8601 $mm {
default '00';
"~^(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})" $m;
}
map $time_iso8601 $dd {
default '00';
"~^(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})" $d;
}
server {
listen 80;
server_name myapp.initech.com;
error_log /sitelogs/initech/myapp/error.$yyyy-$mm-$dd.log;
access_log /sitelogs/initech/myapp/access.$yyyy-$mm-$dd.log;
location / {
root /site/initech/data/myapp;
autoindex on;
}
}
Having reloaded the server and made some test requests, my log directory looks like this:
$ ls -1 /sitelogs/initech/myapp
access.2022-10-28.log
error.$yyyy-$mm-$dd.log
It looks to me like i can use that map directive to set up a variable to be used in the name of the access log, but not the error log. Is that the case?
I could rationalise that as the map directives only running in the context of a particular HTTP request, whereas in some sense the error log has to be set up across all HTTP requests.
If this is the case, is there any way to get a dated error log filename? Our firm has existing log archiving processes which don't play well with filename collisions, so it would be really, really helpful to have dated error log files.