Since there is no reason to waste syslog to report various things for PHP, I decided to write my own wrapper. It’s still quite young, and not overly featureful, but it now exists. It will log to a file of your choice, only dropping to syslog when things break.
function logger($facility=”user:notice”, $message = “”) { global $mylogfile umask(0177); if ($logger != “yes” || empty($message) || empty($logfile)) return; if (!$fp = fopen($logfile,”a+”)) syslog(0,$_SERVER[“PHP_SELF”] . ”: cannot open $mylogfile\n”); $format = (isset($_SERVER[“REMOTE_ADDR”])) ? date(“M-d-Y H:i:s ”) . $_SERVER[“REMOTE_ADDR”] . ” ” : date(“M-d-Y H:i:s ”) . ” unknown ”; $format .= $_SERVER[“PHP_SELF”] . ”$facility” . ucfirst($message) . ”\n”; fputs($fp, $format); fclose($fp); }Trivial logging functionale for PHP programs.