1.cd /usr/local/nginx/conf //进入配置文件夹
2.编辑nginx.conf
在http下添加map{}和access_log
http {
include mime.types;
default_type application/octet-stream;
# 日志样式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# 按天保存文件
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
# 增加一个日志
access_log logs/access-$logdate.log;
3.cd /usr/local/nginx/sbin
执行命令:
./nginx -s reload
3735

被折叠的 条评论
为什么被折叠?



