NpsAwstats用于生成AWStats系列站点统计报告。对于小型站点,建议采用按月或按年方式生成报告;对于中大型站点,建议采用按天甚至按小时生成报告。
1.在NPS服务器上必须安装perl,且在系统环境变量path中包含该路径。在windows环境下可以安装ActivePerl。
2.awstats_include.inc文件调整
如果你使用的是APACHE或Lotus Notes/Domino Combined Log Format格式的日志文件,awstats_include.inc就无须调整。
否则,请按以下说明进行调整。
1)打开{$NPS_HOME}/awstats/conf/awstats_include.inc
找到LogFormat段,根据说明正确设置LogFormat的值。
2)删除或覆盖{$TEMP_ROOTPATH}/awstats/conf/awstats_include.inc文件(如果有)
3.请根据awstats_include.inc中的配置正确配置你的WEB服务器的日志格式。以下以Apache为例进行说明,其他WEB服务器请参见WEB服务器配置说明。
1)Apache的combined log format设置-awstats_include.inc默认采用的格式
CustomLog /logs/httpd/www.jwebstar.com_access_log combined
2)Apache的common log format设置
CustomLog /logs/httpd/www.jwebstar.com_access_log common
4.你也可以在awstats_include.inc中显式指定LogFile参数(参看AWStats配置手册)。
但一旦调用AddNpsFile()或AddFile()函数后该配置将失效。
以下代码演示了按月生成当月访问日志报表。
|
var site = session.GetSite('jwebstar'); var awstats = new NpsAwstats(site,'cn'); awstats.AddFile('/weblogs/jwebstar%YY-24%MM-24%DD-24.log'); var today = new Date(); var year = today.getYear(); if (year < 2000) year = year + 1900; var month = today.getMonth()+1; awstats.ReportAllByMonth(year,month); |
| NpsAwstats |
NpsAwstats(NpsSite site,String lang) 构造函数。 lang为要生成的网页所使用的语言,为二位编码,同国家地区标准代码。en表示英文,cn表示简体中文,tw表示繁体中文。
|
||||||||||||||||||||||||||||||||||||||||||||
| void |
AddNpsFile(NpsFile logfile) 加入多个指定的文件(不能是目录)用于日志分析。 可以多次调用以包含一组日志文件。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
AddFile(String logfile) 加入多个指定的文件用于日志分析,logfile可以使用通配符。可以多次调用以包含一组日志文件。 以下参数可以直接使用(来自AWStats的LogFile的相关说明) # %YYYY-n is replaced with 4 digits year we were n hours ago # %YY-n is replaced with 2 digits year we were n hours ago # %MM-n is replaced with 2 digits month we were n hours ago # %MO-n is replaced with 3 letters month we were n hours ago # %DD-n is replaced with day we were n hours ago # %HH-n is replaced with hour we were n hours ago # %NS-n is replaced with number of seconds at 00:00 since 1970 # %WM-n is replaced with the week number in month (1-5) # %Wm-n is replaced with the week number in month (0-4) # %WY-n is replaced with the week number in year (01-52) # %Wy-n is replaced with the week number in year (00-51) # %DW-n is replaced with the day number in week (1-7, 1=sunday) # use n=24 if you need (1-7, 1=monday) # %Dw-n is replaced with the day number in week (0-6, 0=sunday) # use n=24 if you need (0-6, 0=monday) 例如: "*.log"表示使用所有以.log为后缀的文件 "/weblogs/jwebstar%YY-24%MM-24%DD-24.log"表示使用jwebstar080618.log格式命名的文件,且日期是昨天的日志。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportByYear(int year,String output) throws Exception 按年生成output指定的统计报告,output参见下表。
|
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportAllByYear(int year) throws Exception 按年生成所有的统计报告。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportByMonth(int year,int month,String output) throws Exception 按月生成output指定的统计报告,output参见上表。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportAllByMonth(int year,int month) throws Exception 按月生成所有的统计报告。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportByDay(int year,int month,int day,String output) throws Exception 按天生成output指定的统计报告,output参见上表。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportAllByDay(int year,int month,int day) throws Exception 按天生成所有的统计报告。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportByHour(int year,int month,int day,int hour,String output) throws Exception 按小时生成output指定的统计报告,output参见上表。 |
||||||||||||||||||||||||||||||||||||||||||||
| void |
ReportAllByHour(int year,int month,int day,int hour) throws Exception 按小时生成所有的统计报告。 |