Skip to content

Instantly share code, notes, and snippets.

@obihann
Last active August 29, 2015 13:57
Show Gist options
  • Save obihann/f56f9190daf1c7e3de74 to your computer and use it in GitHub Desktop.
Save obihann/f56f9190daf1c7e3de74 to your computer and use it in GitHub Desktop.
Basic PHP error logging
<?php
// Configure error levels
error_reporting(E_ERROR);
ini_set('display_errors', 1);
// Path to err log
$errorLogs = "/var/www/logs/error.log";
// Obtain IP of remote client
$requestIP = $_SERVER['REMOTE_ADDR'];
// Create error message
$logError = sprintf("\n\n%s - 'function_name' Error (%s) \nerror_string", time(), $requestIP);
// Log error to file
error_log($logError, 3, $errorLogs);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment