Return to Snippet

Revision: 36000
at November 16, 2010 05:42 by sadus


Updated Code
use this line so all your errors are logged.
<?php
error_reporting(E_ALL);
?>

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!

Revision: 35999
at November 16, 2010 05:31 by sadus


Updated Code
use this line so all your errors are logged.
<?php
error_reporting(E_ALL);
?>

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:local2

go to your syslog.conf and set the following at the very end of the file:
local2.*   /var/log/httpd-php.log

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!

Revision: 35998
at November 16, 2010 04:27 by sadus


Initial Code
use this line so all your errors are logged.
<?php
error_reporting(E_ALL);
?>

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:local2

go to your syslog.conf and set the following:
local2.*   /var/log/httpd-php.log

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!

Initial URL


Initial Description
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.

Initial Title
PHP error_log to syslog to a custom file pipe to tail your errors.

Initial Tags
php, error, log, color

Initial Language
PHP