Making Squid log timestamps human readable

By default, squid uses UTC in its timestamps in its various logs (access.log, store.log, cache.log). Although there are many tools to covert UTC into a human readable format – its not always practical when running a grep over your logs for troubleshooting.

In order to change this simply add the following line to your squid conf (make sure to remove or comment any exting entries)

logformat squid %tl.%03tu %6tr %>a %Ss/%03Hs %

The new log youtput will produce something like this:

26/Oct/2010:15:38:46 +0200.538 4787 y.y.y.y TCP_MISS/200 41841 GET - DIRECT/x.x.x.x text/html

Her is a list of the format codes:

% a literal % character
>a Client source IP address
>A Client FQDN
>p Client source port
la Local IP address (http_port)
lp Local port number (http_port)
sn Unique sequence number per log line entry
ts Seconds since epoch
tu subsecond time (milliseconds)
tl Local time. Optional strftime format argument
default %d/%b/%Y:%H:%M:%S %z
tg GMT time. Optional strftime format argument
default %d/%b/%Y:%H:%M:%S %z
tr Response time (milliseconds)
dt Total time spent making DNS lookups (milliseconds)

Use the squid documentary to apply your needs to the logfile: