Time for action – customizing the access log with a new log format
Squid has a lot of information about every client request and reply, however it writes only the requested information to the log file, which we can customize by defining several log formats.
Now, let's define a log format in which the time will appear in a human-readable format and use it with access_log
:
logformat minimal %tl %>a %Ss/%03>Hs %rm %ru access_log daemon:/opt/squid/var/logs/access.log minimal
So, we have constructed a new log format that will log the information we are most interested in. Let's see a few log messages in the preceding format:
11/Sep/2010:23:52:33 +0530 127.0.0.1 TCP_MISS/200 GET http://en.wikipedia.org/wiki/Main_Page 11/Sep/2010:23:52:34 +0530 127.0.0.1 TCP_MISS/200 GET http://en.wikipedia.org/images/wikimedia-button.png
Now the time in the log messages is human-readable and we can therefore tell when a particular URL was accessed.
We should note that if we are using custom formats for access...