John Davidson

php - where do I place CustomLog directive in apache

0 comments
Message:


I am using a php:7.2-apache docker. I need to disable healthcheck url from logging into access log.


Based on this link they mention about modifying Customlog directive. I am not about the file where I need to make the change for Customlog directive.



My Answer:
In a php:7.2-apache docker container, the Apache configuration file where you can place the CustomLog directive is typically located at `/etc/apache2/apache2.conf` or `/etc/apache2/sites-available/000-default.conf`.

To disable logging for a specific URL (such as a healthcheck URL), you can use the SetEnvIf directive in combination with the CustomLog directive. Here's an example of how you can achieve this:

1. Open the Apache configuration file in a text editor:

bash
nano /etc/apache2/apache2.conf


2. Add the following lines at the end of the file:

apache
SetEnvIf Request_URI "^/healthcheck$" dontlog
CustomLog /var/log/apache2/access.log combined env=!dontlog


In this example, requests to the `/healthcheck` URL will not be logged in the access log.

3. Save the file and restart the Apache service for the changes to take effect:

bash
service apache2 restart


Please note that the exact location of the Apache configuration file may vary depending on the specific setup of your docker container. You may need to explore different directories to find the correct configuration file.

Rate this post

3 of 5 based on 5510 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us