2012 from—http://www.144d.com/post-203.html

用以下代码在Nginx的配置文件中打开重写错误日志提示。

1 rewrite_log on;   # 打开 URL 重写模块的日志开关,以便写入 error_log

另外error_log最后那个参数还需要设置成Info.如下:

1 error_log /home/www/logs/nginx_error.log info;

lnmp的集成包,默认设置的是:

1 error_log /home/www/logs/nginx_error.log crit;

并且没有开启rewrite_log on选项,所以重写错误时无法查看错误内容。

 

一下为重写出现错误时的一些日志,仅供参考:

 

01 .168.0.39, request: "GET /default/view/editsort/sort-5-aid-8876.html HTTP/1.1", host: "192.168.0.39:8080"
02 2012/12/25 14:46:40 [notice] 4145#0: *5 rewritten data: "/index.php", args: "ct=default&m=error", client: 192.168.0.188, server: 192.168.0.39, request: "GET /default/view/editsort/sort-5-aid-8876.html HTTP/1.1", host: "192.168.0.39:8080"
03 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
04 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
05 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
06 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)-([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
07 2012/12/25 14:46:42 [error] 4145#0: *5 open() "/home/wwwroot/www.meiyoule.com/favicon.ico" failed (2: No such file or directory), client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
08 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" matches "/error.html", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
09 2012/12/25 14:46:42 [notice] 4145#0: *5 rewritten data: "/index.php", args: "ct=default&m=error", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
10 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
11 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
12 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
13 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)/([^/]+)/([a-z0-9_]+)-([^/-]+)-([a-z0-9_]+)-([^/-]+)\.html$" does not match "/favicon.ico", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
14 2012/12/25 14:46:42 [error] 4145#0: *5 open() "/home/wwwroot/www.meiyoule.com/favicon.ico" failed (2: No such file or directory), client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
15 2012/12/25 14:46:42 [notice] 4145#0: *5 "^/([^/]+)\.html$" matches "/error.html", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
16 2012/12/25 14:46:42 [notice] 4145#0: *5 rewritten data: "/index.php", args: "ct=default&m=error", client: 192.168.0.188, server: 192.168.0.39, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.39:8080"
17 [[email protected] vhost]#