Bootstrap FreeKB - Apache (Web Server) - Create a custom log
Apache (Web Server) - Create a custom log

Updated:   |  Apache (Web Server) articles

Let's take an example where you want requests for your example.html to be written to a log file called example.log. In the Apache httpd.conf file, you would first create a variable for the example.html page. In this scenario, "myexample" is the variable associated with the example.html page.

SetEnvIf Request_URI example\.html myexample

 

Then you would configure Apache to write events to example.log. In this scenario, "common" means you are using the common loglevel directive as the format for example.log. Restart the web server for this change to take effect. Then, navigate to your example.html page, and events should be written to both the access_log and example.log.

CustomLog /path/to/example.log common env=myexample

 

Add the following line to the Apache httpd.conf file if you do not want events written to the access_log.

CustomLog /path/to/access_log common env=!myexample

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter da6d09 in the box below so that we can be sure you are a human.