Related Items  

Linux and Windows Support  

make-it-great-again

Login or Register  

If you wish to contribute an article, please login or register.

Apache Do Not Log

PrintE-mail

apacheQ. I'm trying to clean up my Apache logs. How do I not log certain events, such as local IP?

A. This can be achieved by setting a dontlog option in your configuration files:

For example, let's say you are indexing your site and don't want the local network to appear in the logs, you can add something like this:

SetEnvIf Remote_Addr "192\.168\." dontlog

Keep in mind that SetEnvIf accepts only regular expressions, not CIDR notation, so you can't have 192.168.0.0/24.

You can have a single IP as well:

SetEnvIf Remote_Addr "192\.168\.1\.100" dontlog

Other available options are:

Accept-Language
Host
User-Agent: Browser type
Referer: URL that referred to your site
Remote_Host: hostname of the client.
Remote_Addr: IP address of the client.
Request_Method: Request Method being used (GET, POST, etc.).
Request_Protocol: Name and version of the protocol with which the request was made ("HTTP/1.1")
Request_URI: HTTP request line - thepart  of the URL following the scheme and host portion without the query string.
Server_Addr: IP address of the server on which the request was received.

Examples:

Format:

SetEnvIf option regex donotlog

SetEnvIf Request_URI "^/index\.php/.*$" dontlog

SetEnvIf  Remote_Host  "^spider" dontlog

SetEnvIf  User_Agent "(MSIE)" dontlog

SetEnvIfNoCase Request_URI "\.(gif)|(jpg)|(png)|(css)|(js)|(ico)|(eot)$" dontlog

Remeber to add env=!dontlog at the end of your log string in the configuration file, otherwise your changes will be ignored:

CustomLog /var/httpd/combined.log combined env=!dontlog

 

Comments (1)
Short and sweet
1 Saturday, 28 May 2016 05:03
Antony
Thanks for the post.

Very use full for the quick reader.

Specially Most of them miss env=!dontlog in them conf. You give that information in warning box its good.

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
   
Copyright © 1999 - 2017 Virtual Helpme | m | Original Template: Allrounder