Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Squid Custom Log Formats

    pfSense Packages
    2
    3
    5.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      thekod
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • T
        trendchiller
        last edited by

        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... ;-)

        1 Reply Last reply Reply Quote 0
        • T
          thekod
          last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.