解決Apache的錯(cuò)誤日志巨大的問(wèn)題
1、可以通過(guò)降低log級(jí)別的辦法來(lái)減少日志讀寫(xiě)。
編輯conf文件夾下的httpd.conf,找到如下內(nèi)容:
#
# 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用于調(diào)整記于錯(cuò)誤日志中的信息的詳細(xì)程度。
(參閱ErrorLog指令)??梢赃x擇下列級(jí)別,依照重要性降序排列:
Level Description Example
emerg 緊急 – 系統(tǒng)無(wú)法使用。 “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 錯(cuò)誤情況。 “remature 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 出錯(cuò)級(jí)別信息 “Opening config file …”
默認(rèn)級(jí)別是warn,那么warn級(jí)別以上的日志都會(huì)記錄,會(huì)產(chǎn)生大量“文件不存在”的erro級(jí)別的錯(cuò)誤日志。
建議使用 crit 級(jí)別的設(shè)置,這樣只記錄致命級(jí)別以上的日志,有效減少日志數(shù)量。
把LogLevel warn更改為L(zhǎng)ogLevel crit 然后重啟apache即可。
請(qǐng)關(guān)注我們微信公眾號(hào):mw748219