Awstats 多個 log 的顯示方法

一般大型網站的 Web Servre log 太大,通常會以 logrotate 將 log 分割成為數個檔案。


以 Apache 為例就是像:
access_log.1、access_log.2、access_log.3…以此類推

另外如果使用 Load balance ,也是會產生個 log 檔,但 awstats 預設的 LogFile 是只有一個,在多個 log file 的狀態下,變成無法更新至最新的狀態,這時就要使用 awstats 內建的工具logresolvemerge.pl 來合併 log ,其實用法也很簡單,只要更改網站的設定檔就好了,以本站為例就是編輯 /etc/awstats/awstats.neo.conf

找到 LogFile 的地方,原來預設單個 log 的設定如下:
LogFile=”/var/log/httpd/access_log”

再來就是輸入您 logresolvemerge.pl 的路徑跟 log 的路徑及萬用字元即可。

logresolvemerge.pl 是放在 awstats 安裝路徑的 tools 裡面,因為我的 awstats 是裝在/usr/local/awstats 裡面,所以完整路徑就是 /usr/local/awstats/tools/logresolvemerge.pl 。

另外我是要合併 access_log.1、access_log.2、access_log.3 的 LogFile 更改範例如下:

LogFile=”/usr/local/awstats/tools/logresolvemerge.pl /var/log/httpd/access_log* |”

編輯存檔後,再來執行更新記錄程式即可,如:
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=xxx -update

再來進去您的網址就可以看到合併後輸出的結果了,如:
http://www.yoursite.com/awstats/awstats.pl?config=xxx

8 comments On Awstats 多個 log 的顯示方法

  • 環境是tomcat請問該將logfile指向哪裡呢
    作業系統是win server 2003

  • 已經安裝perl與awstatus了但是不曉得該如何正確設定
    tomcat的版本是5.5版
    站台的入逕是C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT

  • 請neo大大幫幫幫忙^^

  • 使用Awstats 多個 log 的顯示方法,是用來解決單一Logfile過大,

    但如果要一台awstats可以分析多台網頁伺服器的流量該如何處理呢?

    一台可分析多台,

    除了將log拷貝到awstats之外還有別的方法嗎?

  • 高手请帮忙解决,谢谢!
      我假如启用了两个站点,一个是a.web.com, 另一个是b.web.com,我现在想对这两个站点,我现在分析这两个日志,原来awstats.a.web.com.conf日志文件的配置信息为:
    LogFile=”E:\databack\site\a\Log\W3SVC287078791\ex%YY-0%MM-0%DD-0.log”
    现在改为:LogFile=”E:/databack/site/a/cgi-bin/logresolvemerge.pl E:/databack/site/a/Log/W3SVC287078791/ex%YY-0%MM-0%DD-0.log E:/databack/site/b/Log/W3SVC1857510694/ex%YY-0%MM-0%DD-0.log |”
    其它的配置参数修改没问题,因为针对”awstats.a.web.com.conf”更新时没问题,可以升级.但是改成上面那样就不能升级了, E:\databack\site\a\cgi-bin>perl awstats.pl -config=a.web.com -lang=cn

    就出现以下错误提示:
    Update for config “./awstats.a.web.com.conf”
    With data in log file “E:/databack/site/a/cgi-bin/logresolvemerge.pl E:/dat
    aback/site/a/Log/W3SVC287078791/ex070423.log E:/databack/site/b/Log/W3S
    VC1857510694/ex070423.log |”…
    Phase 1 : First bypass old records, searching new record…
    Direct access to last remembered record has fallen on another record.
    So searching new records from beginning of log file…
    AWStats did not find any valid log lines that match your LogFormat parameter, in
    the 50th first non commented lines read of your log.
    Your log file E:/databack/site/a/cgi-bin/logresolvemerge.pl E:/databack/sit
    e/a/Log/W3SVC287078791/ex070423.log E:/databack/site/b/Log/W3SVC1857510
    694/ex070423.log | must have a bad format or LogFormat parameter setup does not
    match this format.
    Your AWStats LogFormat parameter is:
    2
    This means each line in your web server log file need to have “MSIE Extended W3C
    log format” like this:
    date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version c
    s(User-Agent) cs(Referer)
    And this is an example of records AWStats found in your log file (the record num
    ber 50 in your log):
    2007-04-22 16:00:02 GET /images/hotflash_top_right.gif – 124.114.179.106 HTTP/1.
    1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) http://b.web.com/C
    ategory.aspx?CategoryID=19 200 1459
    Setup (‘./awstats.a.web.com.conf’ file, web server or permissions) may be w
    rong.
    Check config file, permissions and AWStats documentation (in ‘docs’ directory).

    请高手帮忙指教,我是在IIS,windows 2003环境下的配置

  • 不好意思,冒昧打擾,想請問一下:
    若IIS Logfile沒有產生IIS Log file(或遺失),則logresolvemerge.pl 的執行會發生錯誤,是否有在合併時忽略不存在logfile的參數可以設定??
    (還是您有其他的好方法可以分享??)

    謝謝!!

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar