I have a Linux Apache server and my error log for PHP is going to /etc/my_custom_php_error_log.log as I mentioned in php.ini file. But I want to create this logs in separate for all my applications. For example I have deployed two applications in this server names Alpha and Bravo and I want to create error logs for Alpha in /var/www/html/Aplha/php_alpha.log and for Bravo in /var/www/html/Bravo/php_bravo.log

How can I do this?


This is done in their various VirtualHost files as thus:

<VirtualHost *:80>

        ServerName ensignremake.app
        DocumentRoot /var/www/html/ensignremake/public/
        DirectoryIndex index.php

    <Directory />
         Options FollowSymLinks
         AllowOverride None

        <Directory /var/www/html/ensignremake>
            AllowOverride All
            Require all granted

        ErrorLog /path/where/you/want/the/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        php_value error_log "/path/where/you/want/the/error.log"

  1. Please note from the most upvoted answer on the link below that other php flags can be set for individual apps but not needed if already set globally in php.

  2. And the right permissions must also be set for your custom locations or apache will write to it's own log files



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.