Squid Custom Log Formats



  • Squid supports custom log formats with the logformat line, like so:

    logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{referer}="">h" "%{User-Agent}>h" %Ss:%Sh
    access_log /usr/local/squid/var/logs/access.log squid</st>
    

    That is to say, you need to add the log format name to the access_log directive, or it will not log using your custom log format.
    After adding both of those lines to the custom options of my Squid (2.6.STABLE18) configuration page in PFSense 1.2 Final, I started getting two lines in the log for every request.  This is caused by the fact that the automated configuration file was writing an access_log directive above, and then I was writing mine below.  While I could have avoided the issue by disabling the "Enabled Logging" option, then entering the two lines in the options, I decided to do things the hard way…I added a custom log format option into the config page, so that you can choose between the default (squid), and whatever custom log format you like.  The input isn't validated, since regular expressions and I still aren't speaking after that little spat in Bolivia.  Anyway, here are the diffs for squid.xml and squid.inc in case anyone else wants custom logging.  You won't be able to patch the files on your pfsense box, since patch isn't included, but you can patch them on another system and upload the files through the web config and copy them from tmp to /usr/local/pkg.  Reply with any issues... ... ...or if this is stupid for some reason I overlooked...
    patch.squid.inc.txt
    patch.squid.xml.txt



  • somehow the inc-diff seems wrong…
    it misses the function tp pass your directives to the cfg-file...
    please pm me the whole changes you made and i'll have a look if it makes sense for us and then decide to submit or not... ;-)



  • Sent.  And it's right.  Or at the very least, it works.  :)
    Thanks!


Locked