Nginx 開啟 debug 日誌的辦法
啟用debug 日誌
--prefix=/usr/local/nginx--with-debug
重新make && make install
編譯,注意:這裡很多說不能make install,只make就好了,其實不然,
在執行./configure命令時則已經查出了原有nginx的各個檔案的路徑,如果原來沒有nginx,則會預設安裝到/usr/local/nginx目錄下。
直接執行make install 則會自動替換原來的nginx,無須手動,也不會中斷nginx程序。
日誌太多,用完就註釋掉
Windows 下的 Nginx 的二進位制版本一般都支援 debug 日誌,因此只需設定 debug 級別即可。
注意如果你重新指定日誌時沒有配置 debug 級別的話,將會禁用 debug 日誌。在下面的例子中,在 server 層面上重新指定的日誌將會禁用這臺伺服器的 debug 日誌:
http {
server {
error_log /path/to/log debug;
}
}
為了避免這種現象的發生,要麼你就註釋掉重新定義的那行日誌,要麼你就在那行也加上 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;
}