392 <LogFormat>
393 <Name = "access"/>
394 <Format = "%<chi> - [%<cqtn>] %<cqhm> %<cquc>/%<cqhv> %<pssc> %<psql> %<crc> %<phr>/%<pqsn> \"%<{User-Agent}cqh>\" %<psct>"/>
395 </LogFormat>
396
397 <LogFilter>
398 <Name = "test_access"/>
399 <Condition = "psct CASE_INSENSITIVE_CONTAIN text/html"/>
400 <Action = "REJECT"/>
401 </LogFilter>
402
403 <LogObject>
404 <Format = "access"/>
405 <Filename = "access"/>
406 <Filters = "test_access"/>
407 </LogObject>
1.这里自定义了日志格式access.log,
2.定义了一个日志收集方式,一个过滤条件,把产生text/html文件的日志过滤掉,非text/html文件日志将写到本地日志
access.log中。
3.自定义日志:
主配置文件records.config:
proxy.config.log.squid_log_enabled INT 0 关闭squid日志
proxy.config.log.custom_logs_enabled INT 1 开启自定义日志指令
日志文件logs_xml.config:
<LogFormat>
<Name = "access"/>
<Format = "%<chi> - [%<cqtn>] \"%<cqhm> %<cquc> TCP/%<cqhv>\" %<pssc> %<psql> \"%<{Referer}cqh>\" \"%<{User-Agent}cqh>\" \"%<crc>\" \"%<{Cookie}cqh>\" \"%<caun>\" "/>
</LogFormat>
<LogObject>
<Format = "access"/>
<Filename = "access"/>
</LogObject>
<LogFormat>
<Name = "atslog"/>
<Format = "%<cquuh> %<chi> %<cqtq> %<crc> [%<cqtn>] \"%<cqhm> /%<cqup> %<cqhv>\" %<pssc> %<psql> \"%<{Referer}cqh>\" \"%<caun>\" \"%<{Cookie}cqh>\" \"%<{User-Agent}cqh>\" %<cqhv> %<cqbl> %<sts> "/>
</LogFormat>
<LogObject>
<Format = "atslog"/>
<Filename = "atslog"/>
</LogObject>
4.此处定义了两种日志格式,access.log和atslog.log
这个是access.log日志:
192.168.199.108 - [19/Jun/2015:16:39:49 +0800] "GET http://www.test100.com/test2.html TCP/HTTP/1.1" 200 539 "-" "curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.12.7.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2" "TCP_MEM_HIT" "-" "-"
192.168.199.108 - [19/Jun/2015:16:40:01 +0800] "GET http://www.test100.com/test2.html TCP/HTTP/1.0" 200 540 "-" "Wget/1.12 (linux-gnu)" "TCP_MEM_HIT" "-" "-"
这个是atslog.log日志
www.test100.com 192.168.199.108 1434703188.161 TCP_HIT [19/Jun/2015:16:39:48 +0800] "GET /test2.html HTTP/1.1" 200 539 "-" "-" "-" "curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.12.7.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2" HTTP/1.1 0 0
www.test100.com 192.168.199.108 1434703189.840 TCP_MEM_HIT [19/Jun/2015:16:39:49 +0800] "GET /test2.html HTTP/1.1" 200 539 "-" "-" "-" "curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.12.7.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2" HTTP/1.1 0 0