How to create a custom log in Apache web server

Home > Search > How-to
  by

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

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments