error_log級別分為debug、info、notice、warn、error、crit,默認為error,crit記錄的日志最少,而debug記錄的日志最多,如果你的nginx遇到問題,比如502頻繁出現,但是看默認的error_log並沒有看到有意義的信息,那么久可以調一下錯誤日志的級別,調成error級別時,錯誤日志記錄的內容會更加豐富,該級別在日志名后邊定義格式如下:
[root@daixuan conf]# vim nginx.conf
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
每個日志級別包括更高級別。例如,如果您將日志級別設置為warn
,則Nginx還將記錄error
,crit
,alert
和emerg
消息。未指定log_level
參數時,默認為error
。
debug
-調試消息。info
-信息性消息。notice
-公告。warn
-警告。error
-處理請求時出錯。crit
-關鍵問題。需要立即采取行動。alert
-警報。必須立即采取行動。emerg
- 緊急情況。系統處於無法使用的狀態。