Filter Apache Access logs Separate Requests From Local Servers

Some requests from local servers is annoying. Need to separate the logs, then the log can focus on users’ requests.

To separate the log, use apache environment variable, modify at apache config file, change the IP range “192.168.1.10/32” to the corresponding IPs.

<If "-R '192.168.1.10/32'">
SetEnv RequestFromLocal
</If>
ErrorLog "|/app/apache/bin/rotatelogs logs/3de_error-%Y-%m-%d.log 86400"
LogFormat "%h %v:%{local}p %l %u %{SSL_PROTOCOL}x %{SSL_CIPHER}x %{User-agent}i %t %{ms}T \"%r\" %>s %b" 3deformat
CustomLog "|/app/apache/bin/rotatelogs logs/3de_access-%Y-%m-%d.log 86400" 3deformat env=!RequestFromLocal
CustomLog "|/app/apache/bin/rotatelogs logs/3de_local-%Y-%m-%d.log 86400" 3deformat env=RequestFromLocal

and then restart apache.

apachectl restart

This Post Has One Comment

Leave a Reply