我想用AwStatsparsingnginx访问日志。
指定的nginx日志格式是
'$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
和日志似乎被正确创build。
AwStats日志格式是
LogFormat = "%host - %logname %time1 %code %methodurl %bytesd %refererquot %uaquot %otherquot"
当我尝试从命令行运行它时,我得到以下错误输出:
Running '"/usr/lib/cgi-bin/awstats.pl" -update -config=default -configdir="/etc/awstats"' to update config default Create/Update database for config "/etc/awstats/awstats.conf" by AWStats version 7.2 (build 1.992) From data in log file "/.../****-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 /.../****-access.log must have a bad format or LogFormat parameter setup does not match this format. Your AWStats LogFormat parameter is: %host - %logname %time1 %code %methodurl %bytesd %refererquot %uaquot %otherquot This means each line in your web server log file need to have the following personalized log format: %host - %logname %time1 %code %methodurl %bytesd %refererquot %uaquot %otherquot And this is an example of records AWStats found in your log file (the record number 50 in your log): 1.2.3.4 - - [20/Sep/2015:14:18:24 +0200] 200 "POST /somescript.php HTTP/1.1" 1277 "http://some.refer.er" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0" "-" Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong. Check config file, permissions and AWStats documentation (in 'docs' directory).
我已经尝试了几个不同的variables(我最初遵循的教程有%code和%methodurl切换,并使用%host_r而不是%logname ),但到目前为止,我没有得到它的工作。
我甚至尝试用-replace%logname -因为我认为丢失的远程用户名可能会混淆AwStats,但无济于事。
对我来说,错误信息中的日志格式和实际日志行看起来应该匹配。 我错过了什么?
这里是我不得不在awstats中使用的日志configuration。
LogFormat = "%host %other %other %time1 %methodurl %code %bytesd %refererquot %uaquot"
这是基于nginx的盒子日志格式