Robin K
Robin K

Reputation: 437

Combine anonymization of IPs in Apache logs using anonip.py with log rotation using Cronolog

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!

Upvotes: 0

Views: 376

Answers (1)

bro
bro

Reputation: 86

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.

Upvotes: 3

Related Questions