修改nginx的http log时间格式
2个文件需要修改
第一个文件:/root/nginx-1.0.11/src/core/ngx_times.c
1、(计算字符串的长度?)
static u_char cached_http_log_time[NGX_TIME_SLOTS]
[sizeof("28/Sep/1970:12:00:00 +0600")];
修改为
static u_char cached_http_log_time[NGX_TIME_SLOTS]
[sizeof("1970-09-28 12:00:00")];
2、(计算字符串的长度?)
ngx_cached_http_log_time.len = sizeof(“28/Sep/1970:12:00:00 +0600“) – 1;
修改为
ngx_cached_http_log_time.len = sizeof(“1970-09-28 12:00:00“) – 1;
3、(关键的地方,修改格式)
p2 = &cached_http_log_time[slot][0];
(void) ngx_sprintf(p2, “%02d/%s/%d:%02d:%02d:%02d %c%02d%02d”,
tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
tm.ngx_tm_year, tm.ngx_tm_hour,
tm.ngx_tm_min, tm.ngx_tm_sec,
修改为
p2 = &cached_http_log_time[slot][0];
(void) ngx_sprintf(p2, “%4d-%02d-%02d %02d:%02d:%02d”,
tm.ngx_tm_year, tm.ngx_tm_mon,
tm.ngx_tm_mday, tm.ngx_tm_hour,
tm.ngx_tm_min, tm.ngx_tm_sec,
第二个文件:/root/nginx-1.0.11/src/http/modules/ngx_http_log_module.c
{ ngx_string(“time_local”), sizeof(“28/Sep/1970:12:00:00 +0600“) – 1,
修改为
{ ngx_string(“time_local”), sizeof(“1970-09-28 12:00:00“) – 1,
近期评论