調整錯誤日志的級別
這幾天 apache錯誤日志巨大 莫名其妙的30G 而且 很多都是那種頁面不存在的 網站太多了 死鏈接相應的也很多
於是把錯誤警告調低了
因為寫日志會給系統帶來很大的損耗。關閉日志以后,甚至最高可以提高整體性能近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 錯誤情況。 “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 …”
默認級別是warn,那么warn級別以上的日志都會記錄,會產生大量“文件不存在”的erro級別的錯誤日志。建議使用 crit 級別的設置,這樣只記錄致命級別以上的日志,有效減少日志數量。
把LogLevel warn更改為LogLevel crit 然后重啟apache即可。
將Httpd.conf 配置文件中的ErrorLog 參數改為下面的,就可以將日志按每天生成一個日志文件.
ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M”
ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400″
以上是關閉apache錯誤日志的辦法!!!
關閉 WEB日志的方法
在httpd.conf文件中,有如下一行,你刪除了就不產生日志了。我是注釋的方式,如:
#CustomLog "logs/access_log" common
這一行可能因你的配置不同有所修改,不一定完全相同。搜索一下就能定位到。方法就這么簡單吧。最后記得要重啟web服務(不用重啟服務器)才有效。