利用apache內建的工具 分割訪問日誌

來源:互聯網
上載者:User

標籤:blog   http   io   os   使用   strong   檔案   div   on   

httpd.conf中CustomLog logs/access.log common 改成
CustomLog "|c:/apache/bin/rotatelogs.exe c:/apache/logs/access_%Y_%m_%d.log 86400" common
其中把c:改成你安裝apache所在的路徑.
重啟Apache

其中c:/apache/是你安裝apache的路徑這樣每一天產生一個記錄檔

  • 在apache的設定檔中找到
    ErrorLog logs/error_log
    CustomLog logs/access_log common

    Linux系統配置方法:

    將其改為
    ErrorLog "| /usr/local/apache/bin/rotatelogs /home/logs/www/%Y_%m_%d_error_log 86400 480"
    CustomLog "| /usr/local/apache/bin/rotatelogs /home/logs/www/%Y_%m_%d_access_log 86400 480" common

    Windows系統下配置方法:

    #ErrorLog "|bin/rotatelogs.exe logs/vicp_net_error-%y%m%d.log 86400 480"
    #CustomLog "|bin/rotatelogs.exe logs/vicp_net_access-%y%m%d.log 86400 480" common

    第一次不知道設定480這個參數,導致日誌記錄時間和伺服器時間相差8小時,原來是rotatelogs有一個offset參數,表示相對於UTC的時差分鐘數,中國是第八時區,相差480分鐘。86400是表示1天。

    附rotatelogs說明

    rotatelogs logfile [ rotationtime [ offset ]] | [ filesizeM ]

    選項
    logfile
    它加上基準名就是記錄檔名。如果logfile中包含’%‘,則它會被視為用於的strftime(3)的格式字串;否則,它會被自動加上以秒為單位的.nnnnnnnnnn尾碼。這兩種格式都表示新的日誌開始使用的時間。
    rotationtime
    記錄檔回卷的以秒為單位的間隔時間
    offset
    相對於UTC的時差的分鐘數。如果省略,則假定為0,並使用UTC時間。比如,要指定UTC時差為-5小時的地區的當地時間,則此參數應為-300。
    filesizeM
    指定回卷時以MB為單位的尾碼字母M的檔案大小,而不是指定回卷時間或時差。

    ---------------

    httpd.conf中CustomLog logs/access.log common 改成

    CustomLog "|c:/apache/bin/rotatelogs.exe c:/apache/logs/access_%Y_%m_%d.log 86400" common

    其中把c:改成你安裝apache所在的路徑.

    重啟Apache

    其中c:/apache/是你安裝apache的路徑這樣每一天產生一個記錄檔

利用apache內建的工具 分割訪問日誌

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.