Giulliano Amendola
Giulliano Amendola

Reputation: 3

How to disable apache log for localhost only

I have two applications on the same machine and communication has occurred through HTTP requests. But my access_log file is very large, and every time one application communicates with another, the system needs to open this large file to write, slowing down the system and even giving IO trouble. Is there any way to block the registration of these localhost requests? I read something about mod_log_config, would that help me?

Upvotes: 0

Views: 898

Answers (1)

Víctor Oriol
Víctor Oriol

Reputation: 566

You can use SetEnvIf with dontlog.

https://httpd.apache.org/docs/2.4/logs.html

There are times when it is convenient to exclude certain entries from the access logs based on characteristics of the client request. This is easily accomplished with the help of environment variables. First, an environment variable must be set to indicate that the request meets certain conditions. This is usually accomplished with SetEnvIf. Then the env= clause of the CustomLog directive is used to include or exclude requests where the environment variable is set. Some examples:

# Mark requests from the loop-back interface
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
# Mark requests for the robots.txt file
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# Log what remains
CustomLog logs/access_log common env=!dontlog

Upvotes: 2

Related Questions