apache2中修改錯誤日誌中的錯誤級別
一、遇到問題因為寫日誌會給係統帶來很大的損耗。關閉日誌以後,甚至最高可以提高整體性能近40%(粗略估計)那麼如何關閉日誌呢?可以通過降低log級別的辦法來減少日誌讀寫。 這裏要提醒的是,這麼做將給“入侵檢測”以及其他基於日誌分析的工作帶來麻煩。所以請謹慎使用。
二、解決問題
編輯conf文件夾下的httpd.conf,找到如下內容:
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
其中LogLevel用於調整記於錯誤日誌中的信息的詳細程度。(參閱ErrorLog指令)。可以選擇下列級別,依照重要性降序排列:
Level Description Example
emerg 緊急 - 係統無法使用。 "Child cannot open lock file. Exiting"
alert 必須立即采取措施。 "getpwuid: couldn't determine user name from uid"
crit 致命情況。 "socket: Failed to get a socket, exiting child"
error 錯誤情況。 "Premature end of script headers"
warn 警告情況。 "child process 1234 did not exit, sending another SIGHUP"
notice 一般重要情況。 "httpd: caught SIGBUS, attempting to dump core in ..."
info 普通信息。 "Server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers)..."
debug 出錯級別信息 "Opening config file ..."
默認級別是warn,那麼warn級別以上的日誌都會記錄,會產生大量“文件不存在”的erro級別的錯誤日誌。建議使用 crit 級別的設置,這樣隻記錄致命級別以上的日誌,有效減少日誌數量。 把LogLevel warn更改為LogLevel crit 然後重啟apache即可。
原帖地址:https://www.cnblogs.com/7bus/archive/2010/08/17/1801734.html
最後更新:2017-04-03 20:19:10