譯序:一般來講,Nginx 的錯誤日志級別是 error,作為 Nginx 用戶來講,你設置成 info 就足夠用了。
但有時有些難以挖掘的 bug,需要看到更詳細的 debug 級別的日志,這時候,單單把 error_log 級別設置成 debug 是不行的,Nginx 記錄下來的還是 info 級別以上的信息。你需要激活 Nginx 的 debug 日志才可以得到 debug 級別的日志信息。本文簡要介紹了 Nginx debug 日志的激活和配置使用。官方正文如下:
要激活 debug 日志,Nginx 在構建時需要配置為支持 debug:
./configure --with-debug ...
然后可以通過 error_log 指令設置 debug 級別:
error_log /path/to/log debug;
Windows 下的 Nginx 的二進制版本一般都支持 debug 日志,因此只需設置 debug 級別即可。
注意如果你重新指定日志時沒有配置 debug 級別的話,將會禁用 debug 日志。在下面的例子中,在 server 層面上重新指定的日志將會禁用這台服務器的 debug 日志:
error_log /path/to/log debug;
http {
server {
error_log /path/to/log;
...
為了避免這種現象的發生,要么你就注釋掉重新定義的那行日志,要么你就在那行也加上 debug 級別:
error_log /path/to/log debug;
http {
server {
error_log /path/to/log debug;
...
也可以只為 特定的客戶端地址發來的請求開啟 debug 日志:
error_log /path/to/log;
events {
debug_connection 192.168.1.1;
debug_connection 192.168.10.0/24;
}
原文鏈接: http://nginx.org/en/docs/debugging_log.html。
但有時有些難以挖掘的 bug,需要看到更詳細的 debug 級別的日志,這時候,單單把 error_log 級別設置成 debug 是不行的,Nginx 記錄下來的還是 info 級別以上的信息。你需要激活 Nginx 的 debug 日志才可以得到 debug 級別的日志信息。本文簡要介紹了 Nginx debug 日志的激活和配置使用。官方正文如下:
要激活 debug 日志,Nginx 在構建時需要配置為支持 debug:
./configure --with-debug ...
然后可以通過 error_log 指令設置 debug 級別:
error_log /path/to/log debug;
Windows 下的 Nginx 的二進制版本一般都支持 debug 日志,因此只需設置 debug 級別即可。
注意如果你重新指定日志時沒有配置 debug 級別的話,將會禁用 debug 日志。在下面的例子中,在 server 層面上重新指定的日志將會禁用這台服務器的 debug 日志:
error_log /path/to/log debug;
http {
server {
error_log /path/to/log;
...
為了避免這種現象的發生,要么你就注釋掉重新定義的那行日志,要么你就在那行也加上 debug 級別:
error_log /path/to/log debug;
http {
server {
error_log /path/to/log debug;
...
也可以只為 特定的客戶端地址發來的請求開啟 debug 日志:
error_log /path/to/log;
events {
debug_connection 192.168.1.1;
debug_connection 192.168.10.0/24;
}
原文鏈接: http://nginx.org/en/docs/debugging_log.html。