NGINX 日志处理 之六

1、定义NGINX错误日志

worker_processes  1;
events {
        worker_connections  1024;
}
error_log  logs/error.log;        #定义日志路径,默认级别为error,配置位置main体里
http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        include vhost/*.conf;
}

2、定义NGINX访问日志

worker_processes  1;
events {
        worker_connections  1024;
}
error_log  logs/error.log;
http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '     #只允许在http模块里配置,此格式为默认定义
                                            '$status $body_bytes_sent "$http_referer" '
                                            '"$http_user_agent" "$http_x_forwarded_for"';

        access_log  logs/access.log  main;     #日志存放路径与使用的格式

        include vhost/*.conf;
}

3、NGINX日志切割

请参考:http://ibm.chick.blog.163.com/blog/static/144201610201621135441819/

猜你喜欢

转载自blog.51cto.com/12965094/2144995
今日推荐