/ Published in: PHP
So i wanted to spit all my error_log(); and error_reporting(E_ALL); to syslog on my MacOSX and syslog would output it on a custom file.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
use this line so all your errors are logged. <?php ?> go to your php.ini and set the following: error_log = syslog go to your apache.conf (httpd.conf) and set the following: ErrorLog syslog:local3 go to your syslog.conf and set the following at the very end of the file: local3.* /var/log/httpd-php.log then look for a line like this: *.notice;authpriv,remoteauth,ftp,install,internal.none /var/log/system.log and add local3.none *.notice;authpriv,remoteauth,ftp,install,internal.none /var/log/system.log this will make sure httpd php errors won't log to your /var/log/system.log file that's reserved for your machine logs. and you are set when you want to log something, use error_log(); example: error_log("Error: " .$user. " is not authenticated"); and then to view your errors in real time: tail -F /var/log/httpd-php.log you can also color this using "colorize" on OSX/FreeBSD or "ccze" on Linux. enjoy!