Nginx作为代理服务器的功能,可以为网站访问时配置访问日志和错误日志。
1.在配置Nginx的访问日志之前,需要先在http配置将 access_log 开启
2.在sever的配置中对错误日进行配置。如下:
server {
access_log /cjzc/cjzcaccess.log;
error_log /cjzc/cjzcerror.log; debug(表示错误的级别)
#other config
}
error_log的错误级别有:debug,info,notice,warn,error,crit。其中crit记录的日志最少,而debug记录的日志的最多。
3.Nginx的Location指定错误日志
为了调试一个应用的部分,可以在一个或是多个location{..}中指定error_log指令。如下:
server{
error_log /cjzc/logs/cjzcaccess.log;
location /admin/ {
error_log /cjzc/logs/adminerror.log
}
#other config
}
以上将仅仅调试应用程序下面的admin的错误信息,同时会将错误信息写入到adminerror.log日志中。