Disable Logging in an Apache VirtualHost

VirtualHosts and logs are invaluable features of a web server. However, you may not always want to log things for every VirtualHost. If you simply comment out the logging commands of a VirtualHost, then transfers to and from the VH will be logged to the main (ie, parent) log file; commenting them does not disable logging for a VirtualHost.

If you want to disable logging for a VirtualHost, one option is to log to a file in a temporary directory that gets flushed regularly, but a better solution is instead to have it log to a non-existent file (nul in Windows, /dev/null in *nix/Mac), such as in the following—mixed example—commands:

<VirtualHost …>

ErrorLog nul
CustomLog "nul" common
CustomLog dev/nul referer
CustomLog "dev/nul" agent

</VirtualHost>

Leave a Reply

Your email address will not be published.

seventeen − 7 =