在CentOS 6上使用awstats分析httpd和tomcat日志(续)

3、其实,还可以使用LoadPlugin="graphgooglechartapi" 插件,利用google chart创建图表。

五、使tomcat的分析页面也显示浏览器和操作系统的图标
由于tomcat的日志格式与apache的格式设置的不同,导致tomcat日志分析的时候出现如下情况:

1、本来以为是图片不对,在网上找了一天,发现并不和网上说的错误一致,所以还是自己想办法。
苦苦纠结中,就想到了日志格式这点上:输出的日志并没有操作系统的版本,也没有浏览器的信息,awstats当然不能分析出其所对应的图标了。(*^__^*) 嘻嘻……
Tomcat的默认日志格式类型与apache一样,都是common,然而awstats分析的是combined类型的。如上所知,我的tomcat类型就是common型的,所以要改为combined型的。
2、重新定义tomcat日志格式:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t&quot;%r&quot; %s %b %{Referer}i %{User-Agent}i" />
输出的日志为:
10.100.0.7 - - [31/Aug/2012:13:34:29 +0800]"GET /docs/proxy-howto.html HTTP/1.1" 200 15550 http://10.100.10.10:8080/docs/setup.html Mozilla/5.0 (Windows NT 5.2; rv:13.0) Gecko/20100101 Firefox/13.0.1
3、这下就全好了,不能高兴的太早,要先测试一下:
# cd /usr/local/awstats/wwwroot/cgi-bin
# perl awstats.pl -update -config=buoqu.com
Create/Update database for config "/etc/awstats/awstats.buoqu.com.conf" by AWStats version 7.0 (build 1.976)
From data in log file "/var/log/httpd/localhost_access_log.2012-08-29.txt"...
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 /var/log/httpd/localhost_access_log.2012-08-29.txt 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 - - [10/Jan/2001:02:14:14 +0200] "GET / HTTP/1.1" 200 1234
And this is an example of records AWStats found in your log file (the record number 50 in your log):
203.208.60.231 - - [29/Aug/2012:00:02:47 +0800] "GET /front/magazine/getContent.htm?contentId=52253 HTTP/1.1" 200 18419 http://10.100.10.10:8080/docs/setup.html Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Setup ('/etc/awstats/awstats.buoqu.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
4、细心的朋友会发现,错误正好跟以前的相反所以将我们以前定义的格式
LogFormat ="%host %other %logname %time1 %methodurl %code"
注释掉或者删掉,就用默认的格式即可。但是有一点,还必须知道:
LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"
%refererquot Referer page with format: "http://from.com/from.htm"
%referer Referer page with format: http://from.com/from.htm
%uabracket User agent with format: [Mozilla/4.0 (compatible, ...)]
%uaquot User agent with format: "Mozilla/4.0 (compatible, ...)"
%ua User agent with format: Mozilla/4.0_(compatible...)
这里有格式的区别,如%refererquot %uaquot" 需要输出的日志有“”,而我们的日志是没有的,所以还要改变LogFormat格式,使其完全一致。
LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %referer %ua"
这样之后,awstats才能完全真正的分析tomcat日志了。
效果如图:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章