Hi.
Rather than rotating logs, I name my access log files like
access-YEAR-MONTH.log.
Is this possible with nginx? I was looking a variable containing the
current date, but did not find any.
TIA,
Anders.
Hi.
Rather than rotating logs, I name my access log files like
access-YEAR-MONTH.log.
Is this possible with nginx? I was looking a variable containing the
current date, but did not find any.
TIA,
Anders.
cron everyday at 23:55 mv path/to/your/log date +%Y%m%d
.log
should do the same ^^
On Wed, Nov 4, 2009 at 6:28 PM, Anders M.
On Wed, 4 Nov 2009 18:41:42 +0700, Kiswono P. [email protected]
wrote:
Rather than rotating logs, I name my access log files like
access-YEAR-MONTH.log.cron everyday at 23:55 mv path/to/your/log
date +%Y%m%d
.log
should do the same ^^
No, that is log rotation, and I don’t like that because one has
to do things at exactly the right time to have everything end up
in the right place.
I find it nicer to just write to the final filename right away.
Anders.
Anders M. [email protected] writes:
Rather than rotating logs, I name my access log files like
access-YEAR-MONTH.log.Is this possible with nginx? I was looking a variable containing the
current date, but did not find any.
Hello again.
I made the below quick patch and configuration like this:
if ($timestamp ~ "^(\d\d\d\d)/(\d\d)/(\d\d)
(\d\d):(\d\d):(\d\d)") {
set $year $1;
set $month $2;
set $day $3;
set $H $4;
set $M $5;
set $S $6;
}
access_log /var/log/http/$host/access-$year-$month.log;
I just glued together a few pieces that seemed about right, so I am
sure that there are all kinds of things wrong with the patch. But it
seems to mostly work, at least as an example of what I am looking for.
Is something like this possible with the stock nginx?
Cheers,
Anders.
diff -ur nginx-0.7.63-orig/src/http/ngx_http_variables.c
nginx-0.7.63/src/http/ngx_http_variables.c
— nginx-0.7.63-orig/src/http/ngx_http_variables.c 2009-05-22
13:32:17.000000000 +0200
+++ nginx-0.7.63/src/http/ngx_http_variables.c 2009-11-16
18:05:21.000000000 +0100
@@ -56,6 +56,8 @@
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t
*r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_timestamp(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t
*r,
@@ -195,6 +197,9 @@
{ ngx_string(“request_method”), NULL,
ngx_http_variable_request_method, 0, 0, 0 },
{ ngx_string(“timestamp”), NULL,
ngx_http_variable_timestamp, 0, 0, 0 },
{ ngx_string(“remote_user”), NULL, ngx_http_variable_remote_user,
0, 0, 0 },
{ ngx_string(“body_bytes_sent”), NULL,
ngx_http_variable_body_bytes_sent,
@@ -1208,6 +1213,26 @@
static ngx_int_t
+ngx_http_variable_timestamp(ngx_http_request_t *r,
v->len = ngx_cached_err_log_time.len;
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
v->data = ngx_cached_err_log_time.data;
v->not_found = 1;
+static ngx_int_t
ngx_http_variable_remote_user(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs