Welcome! Log In Create A New Profile

Advanced

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

Francis Daly
October 24, 2014 03:22AM
On Thu, Oct 23, 2014 at 07:17:20PM -0400, newnovice wrote:

Hi there,

> Where I am going with this is - I want to write error & access - logs out
> with the 'YYYY-MM-DD-HH' suffix. So i need these variables.

I'm not aware that error_log takes variables.

You may be happier moving the log files to time-named versions and then
signalling nginx to re-open the log files, every hour.

http://nginx.org/en/docs/control.html

> The 'if' statement is not allowed outside the server{} - I am at a loss due
> to this.

if() doesn't work for you inside location{}, and it is not allowed
outside server{}. What happens if you put it inside server{} but outside
location{}?

> Please con you show me some examples of how to set these variables
> with a map regex?

Untested, but given that you already have

if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}

then I would expect that something like

map $time_iso8601 $year {
"~^(?P<one>\d{4})-(\d{2})-(\d{2})" $one;
}

would do the right thing.

> I can have 4 seoerate maps to get it done - doesn't matter.

If you want to use map for this, then you would need multiple ones. But
I suspect that variable-in-log-file-name is not what you want.

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

can a map + regex be used to generate variables for YYYY-MM-DD-HH?

newnovice October 23, 2014 02:00AM

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

Francis Daly October 23, 2014 05:06PM

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

newnovice October 23, 2014 07:17PM

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

Francis Daly October 24, 2014 03:22AM

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

newnovice October 24, 2014 01:44PM

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

Francis Daly October 24, 2014 02:14PM

Re: can a map + regex be used to generate variables for YYYY-MM-DD-HH?

newnovice October 24, 2014 05:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready