I need to apply a mask to IP in the log of Apache.
For example, I have this log : 192.168.234.111 - - [18/Oct/2013:16:29:40 +0200] "GET ........"
And I want to save that : 192.168.234.xxx - - [18/Oct/2013:16:29:40 +0200] "GET ........"
To do the first log, I'm using log format like this.
LogFormat "%h %l %u %t" combined-syslog2
CustomLog /var/log/toto combined-syslog2
To have the second log, I can pipe a perl/shell post script like that :
CustomLog |/usr/local/shl/apache_syslog2
But I'm not happy with this solution. Is it possible to do that with Apache ?
Thanks.
Eric
Here's the way to do it in Apache:
RewriteCondition
which matches all IP addressesRewriteRule
to store the partial IP plus xxx in an environment variable (e.g. VARNAME
)LogFormat
declaration via %{VARNAME}e
References