Local time in the Squid log

From V.S.V., Inc.
Jump to: navigation, search

The default Squid Proxy log uses epoch seconds in the first field to show when the record was created. In and of itself this is fine but, epoch seconds are challenging for humans to understand. This is compounded by the fact that there is no consistent standard for when the epoch started.

tail -f /var/log/squid/access.log|perl -e ‘while(){$x=$_; ($date, $rem) = split(/\s+/, $x, 2); print scalar(localtime($date)). ” $rem”;}’

The above one liner continuously tails the access.log file and converts the first field to a human readable format in the local time zone.