標籤:des style blog class c code
調整錯誤記錄檔的層級
這幾天 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檔案中,有如下一行,你刪除了就不產生日誌了。我是注釋的方式,如:
?
| 1 |
#CustomLog "logs/access_log" common |
這一行可能因你的配置不同有所修改,不一定完全相同。搜尋一下就能定位到。方法就這麼簡單吧。最後記得要重啟web服務(不用重啟伺服器)才有效。