[squid-users] Force ASCII encoding for access.log fields?

From: Mark DeCheser <lists_at_decheserstudios.com>
Date: Thu, 26 Jun 2014 23:25:54 -0000

Hi everyone --

I recently ran into a strange condition within my Squid access logs which
is making importing the events into a database a bit more difficult.
Note, I am not logging directly to a database, but rather parsing event
into a centralized database via batch/cron.

Events in the access log, mainly which I see are in the ContentType field,
are being recorded as non-ASCII characters. When I attempt to import the
log into PostgreSQL, psql barfs.

Our logfile format in our Squid config looks like this:

logformat my-custom %la,%>a,%10tr,%>st,%<st,%rm,%03>Hs,%mt,%[un,%tg
access_log /var/log/squid/access.log my-custom

Some examples of the events look like this:



I'm running Squid instances on VPSes in a number of different countries.
This particular Squid instance is in Norway, and coincidentally enough
happens to be the only VPS delivered to my organization that wasn't
already set to en_US.UTF-8.

# cat /etc/sysconfig/i18n
# echo $LANG

It could be a coincidence, but based on the fact that I have instances all
over the world, and only this instance is giving me trouble ... I found it
to be an odd coincidence.

Ideally, if it's possible for Squid to force some kind of hex encoding for
this Content-Type (or really, for any field that receives non ASCII
characters), that would be optimal. There are downstream alternatives
which include finding / replacing non-ASCII chars in a preparation script.
 There's also the option to change the charset of the database itself so
that it doesn't complain about the charset, but these alternatives seem a
little reactionary.

I've reviewed: http://www.squid-cache.org/Doc/config/logformat/
I also tried using iconv unsuccessfully:

It essentially leaves me with offset fields/columns in the logfile.

I also reviewed Amos' comment here:

The difference in my case is that I'm dealing with Content-Type, not URL.
The potential for this condition to be found elsewhere is within the realm
of possibility (username, for example), but presently not an immediate

The community's advice would be greatly appreciated.

Mark DeCheser
Received on Thu Jun 26 2014 - 23:25:21 MDT

This archive was generated by hypermail 2.2.0 : Fri Jun 27 2014 - 12:00:05 MDT