Search code examples
phpapacheerror-logging

Can you log php errors to multiple files?


Is it possible to send the same error to a global php error log in /var/log/php_errors as well as send the same error to a local error log in /var/www/mysite/php_errors?

On our staging server, I tail the log file, and a lot of wordpress stuff as well as some big ugly print_r's will come through from other developers. I'd like to have a global error file to see if there is anything breaking server wide from time to time, as well as separate out my local errors so I can follow them better if I'm only interested in one site at the moment.


Solution

  • Not that I am aware of. However, you could use the error_prepend_string ini setting and prepend all of your error logs with something. And then when you tail your log files you can grep on whatever you set and it will show you only messages from that site (so long as you choose something fairly unique.)

    http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-prepend-string