0%

如何自定义Squid日志格式, 添加请求方法等参数

Squid手册,找到你需要添加的参数:

1
2
3
4
5
6
7
Field name syntax keys:
...
%rm
Request method
%ru
Request URL, without the query string
...

修改Squid配置文件/etc/squid/squid.conf,在logformat开头的这一行中添加%rm %ru参数,如下所示:

1
2
logformat customized  %tl %ts %6tr %>a %Ss %03>Hs %>st %<st %[un %Sh %<A %mt "%{User-Agent}>h" %03<Hs "%rm %ru HTTP/%rv" %err_code
access_log /var/log/squid/access.log customized

重启Squid, 查看access.log, 发现日志格式已成功修改

参考

http://www.squid-cache.org/Doc/config/logformat/