If you're not into using the PHP Error Handling Functions (http://www.php.net/manual/en/ref.errorfunc.php) that the other replies have mentioned, here is a deadly simple Logger class that I've used before. Standard warnings apply, as I have not used it in a high risk application or on a heavily trafficked site (though it should be fine).
private static function addEntry($str)
$handle = fopen('./services.log', 'a');
fwrite($handle, sprintf("%s %s\n", date('c'), $str));
public static function warn($str)
public static function info($str)
public static function debug($str)
Then you can use it like this:
Very simple to add more functions (like Logger::error()), store the file handler so you don't have to keep re-opening it every time you want to log something (ie., store the $handle variable in a private static class scope variable, and have addEntry() check to see if it's set whenever it's run and run fopen() if it isn't), or change the format of how you're logging.