0

I sure hope I've come to the right place.

I want to anonymize IP addresses in log files (see here) while also rotating log files with Cronolog on Ubuntu 16.04.

This is a slight derivation of my current CustomLog entry:

CustomLog "|/usr/bin/python2.7 /var/www/anonip.py --output |/usr/bin/cronolog /var/www/test.mydomain/log/%Y-%m/access_%d.log" combined

It does work if I omit cronolog, but not with it. Does anyone know how to make this work? Alternatives are also appreciated. Thanks!

Robin K
  • 437
  • 6
  • 17

1 Answers1

3

Build a logging pipe composed of multiple commands with:

CustomLog "|$ /usr/bin/python2.7 /var/www/anonip.py | /usr/bin/cronolog /var/www/test.mydomain/log/%Y-%m/access_%d.log" combined

(omitted option --output which would write the anonymized log to a file instead of stdout)

With |$ ... instead of | ... Apache2's CustomLog starts a shell with can start multiple commands in a pipe instead of a single command as explained in Apache2 Manual - Piped Logs.

bro
  • 76
  • 3