batsh 发表于 2015-8-20 08:25:13

awstats分析apache日志格式问题

我的apache日志格式是这样设置的 (因为是生产环境的,如果需要修改要申请一次性改掉,所以要确定问题再去修改)
# ---------------
# Log file settings
# ---------------
ErrorLog "|/usr/local/sbin/cronolog /data/apache2/logs/error-%Y-%m-%d.log"
LogLevel warn
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %T %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %T %b" common
    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %T %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    SetEnvIf Request_URI ^/ap2_snmp dontlog
    CustomLog "|/usr/local/sbin/cronolog /data/apache2/logs/access-%Y-%m-%d.log" combined env=!dontlog
</IfModule>



我分析的日志是access-%Y-%m-%d.log


awstats的日志格式我选择的是1 combined,但是还是会报我apache格式不符合的错误

# /usr/local/awstats/tools/awstats_updateall.pl now -configdir=/etc/awstats

Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=test.cn -configdir="/etc/awstats"' to update config test.cn
Create/Update database for config "/etc/awstats/awstats.test.cn.conf" by AWStats version 7.4 (build 20150714)
From data in log file "/data/log/access.log"...
Phase 1 : First bypass old records, searching new record...
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 /data/log/access.log must have a bad format or LogFormat parameter setup does not match this format.
Your AWStats LogFormat parameter is:
1
This means each line in your web server log file need to have "combined log format" like this:
111.22.33.44 - - "GET / HTTP/1.1" 200 1234 "http://www.fromserver.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
And this is an example of records AWStats found in your log file (the record number 50 in your log):
61.134.14.237 - - "GET /meeting/static/default/css/zh_cn/index.css HTTP/1.1" 200 0 59725 "http://hiersun.test.cn/meeting/proxy.action" "Mozilla/5.0 (Windows NT 6.2; WOW64; Trident/7.0; rv:11.0; 2345Explorer 4.2.0.13929) like Gecko"
Setup ('/etc/awstats/awstats.test.cn.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

sky 发表于 2015-8-20 13:26:26

like this:
111.22.33.44 - - "GET / HTTP/1.1" 200 1234 "http://www.fromserver.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"

sky 发表于 2015-8-20 13:27:30

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
改成这样试一下

batsh 发表于 2015-8-20 14:54:50

找到原因了,是awstats的combined的默认格式跟我使用的apache格式不一样,awstats是LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"我的比它多一个参数LogFormat "%h %l %u %t \"%r\" %>s %T %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

所以我把awstats的格式变成LogFormat = "%host %other %logname %time1 %methodurl %code %other %bytesd %refererquot %uaquot"
问题解决。
页: [1]
查看完整版本: awstats分析apache日志格式问题