寻找 awstats 的 LogFormat 来读取我的自定义 apache 日志文件

寻找 awstats 的 LogFormat 来读取我的自定义 apache 日志文件

我的 apache-2.4 LogFormat:

LogFormat "%h %l %u %t \"%r\" %>s %b ref=\"%{Referer}i\" ua=\"%{User-Agent}i\" host=\"%{Host}i\" xff=\"%{X-Forwarded-for}i\""

供参考的日志文件行示例:

"10.10.10.200 - - [29/Jan/2017:03:45:15 +0100] "GET /health-check/97b0d3c3dd9cfaf7f532aed814f2a049 HTTP/1.0" 200 19 ref="-" ua="-" host="10.10.10.10" xff="-""

我的问题似乎是将此处写入的 IPhost="10.10.10.10"放入 awstats 的 %host 变量中。我认为这是因为 IP 周围有引号。如您所见,我尝试将引号括起来,但似乎不起作用。所以我基本上是在寻找一种方法来告诉 awstats IP 是在双引号中,它应该将该 IP 写入 %host 变量中。

我迄今为止对 awstats 的尝试LogFormat(+ 其中一些略有变化)。 在早期的尝试中,我仍然认为第一列的 IP 对我来说是正确的,但事实并非如此

#LogFormat="%host - - %time1 %methodurl %code %bytesd ref=%refererquot ua=%uaquot host=\"%extra1\" xff=\"%extra2\""
#LogFormat="%host %other %other %time1 %methodurl %code %bytesd %refererquot %uaquot %other %other"
#LogFormat="%h %l %u %t \"%r\" %>s %b ref=\"%{Referer}i\" ua=\"%{User-Agent}i\" host=\"%{Host}i\" xff=\"%{X-Forwarded-for}i\""
#LogFormat="%host - - %time1 %methodurl %code %bytesd %refererquot %uaquot \"%extra1\" \"%extra2\""
#LogFormat="%other - - %time1 %methodurl %code %bytesd ref="-" ua=%uaquot host=\"%host\" xff=%otherquot"
#LogFormat='%other - - %time1 %methodurl %code %bytesd ref="-" ua=%uaquot host="%host" xff=%otherquot'

我收到的错误是:

Error: Your personalized LogFormat does not include all fields required by AWStats (Add %host in your LogFormat string).

或者

AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.

或者我可能完全走错了路,在这种情况下,我愿意接受建议;-)

答案1

这是我最终想到的:

LogFormat="%other - - %time1 %methodurl %code %bytesd ref=\"%referer\" ua=\"%ua\" host=%host xff=%extra1"

显然使用%uaquote%refererquot会产生误导,因为它无法像我想象的那样使用双引号。而将真实主机放入 awstats 的唯一方法是使用host=%host,这意味着主机现在在 awstats 中被双引号括起来。

相关内容