PHP Output to Syslog on Ubuntu

There are just a few things you need to know in order to output trace or error information to syslog on an Ubuntu system from PHP (the following is probably true for other Debian-based distributions, too).

  • Set error logging to syslog in php.ini (the system-wide php.ini can be found at /etc/php5/php.ini):
error_log = syslog
  • Restart Apache:
$ sudo /etc/init.d/apache2 restart

Use the error_log() function to output your error messages.

  • View the output of error messages:
$ tail -f /var/log/syslog

The -f flag causes new messages to be appended to the output of tail.

Tags: ,