-   Linux - General (
-   -   Adding date and time to Squid access.log (

jonette20 10-04-2007 11:37 AM

Adding date and time to Squid access.log

In Squid, my access.log does not show time & date like the cache.log.
It allows you to insert a time & date, but how do u set it up to show the time and date automatically?


bathory 10-05-2007 04:44 AM

Open your squid.conf and search for the line that starts with access_log or cache_access_log and looks like:

access_log /var/log/squid/access.log squid
Of course the path to the logfile may vary in your case.
Note the last keyword (in this case squid, but it could be common, combined, squidmime). Then look for the line that starts with logformat <keyword> and change "%ts.%03tu" with "%tl" fro local time or "%tg" fro GMT time. If the line does not exist you should add it. For the above example it should changed from:

logformat squid  %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt

logformat squid %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
You can take a look at squid.conf.default that comes with squid and it's well documented to see other available options for customizing your logs.


madsere 05-31-2008 01:11 AM

This is not correct. If you add the "logformat" keyword to squid.conf it throws an error on restart:

Stopping squid: 2008/05/31 05:03:28| parseConfigFile: line 704 unrecognized: 'logformat squid %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt'

You can get the date by adding the line:

emulate_httpd_log on

This is explained in the squid.conf.default:

# TAG: emulate_httpd_log on|off
# The Cache can emulate the log file format which many 'httpd'
# programs use. To disable/enable this emulation, set
# emulate_httpd_log to 'off' or 'on'. The default
# is to use the native log format since it includes useful
# information Squid-specific log analyzers use.
# emulate_httpd_log off

jonette20 06-02-2008 12:32 PM


I used the logformat line in my squid.conf file and had no problems when Squid started up.
My access.log is now showing the time and date, as I wanted.

Not saying that madsere didn't get an error, just saying that it was the correct solution for me.


madsere 06-03-2008 12:12 AM

Maybe different versions of Squid? I use Version 2.5.STABLE6.

jazz13 09-21-2009 08:41 AM

helped me, thanks for info

All times are GMT -5. The time now is 01:40 AM.