解決Apache的錯誤日志巨大的問題

apache by 黃業(yè)興 at 2019-11-27

1、可以通過降低log級別的辦法來減少日志讀寫。

編輯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)整記于錯誤日志中的信息的詳細(xì)程度。

(參閱ErrorLog指令)??梢赃x擇下列級別,依照重要性降序排列:

Level Description Example

emerg 緊急 – 系統(tǒng)無法使用。 “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 錯誤情況。 “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 出錯級別信息 “Opening config file …”

默認(rèn)級別是warn,那么warn級別以上的日志都會記錄,會產(chǎn)生大量“文件不存在”的erro級別的錯誤日志。

建議使用 crit 級別的設(shè)置,這樣只記錄致命級別以上的日志,有效減少日志數(shù)量。

把LogLevel warn更改為LogLevel crit 然后重啟apache即可。

請關(guān)注我們微信公眾號:mw748219