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 ...

Get Squid Proxy Server 3.1 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.