LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Adding date and time to Squid access.log (http://www.linuxquestions.org/questions/linux-general-1/adding-date-and-time-to-squid-access-log-589410/)

jonette20 10-04-2007 10:37 AM

Adding date and time to Squid access.log
 
Hi,

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?

Thanks
jonette20

bathory 10-05-2007 03:44 AM

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

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:
Code:

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

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.

Regards

madsere 05-31-2008 12: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.
#
#Default:
# emulate_httpd_log off

jonette20 06-02-2008 11:32 AM

Hi,

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.

FYI

madsere 06-02-2008 11:12 PM

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

jazz13 09-21-2009 07:41 AM

helped me, thanks for info


All times are GMT -5. The time now is 04:55 AM.