xxxxxxxxxx
// Php Error Log
error_log("Error message");
// Log and Array
error_log( print_r( [
__METHOD__,
'error_key_1' => 'error_value'
] ) );
xxxxxxxxxx
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
xxxxxxxxxx
ini_set("log_errors", 1); // Enable error logging
ini_set("error_log", "/tmp/php-error.log"); // set error path
error_log( "Hello, errors!" ); // log a test error
xxxxxxxxxx
ini_set("log_errors", 1); // Enable error logging
ini_set("error_log", "/tmp/php-error.log"); // set error path
xxxxxxxxxx
The error_log() function is used to send an error message to the
web server's error log, a TCP port or to a file.
The error message that should be logged.
xxxxxxxxxx
// You can easily create your own function to handle logging, like so:
/***
Simple function to log a value to a text file
Takes 1 parameter: the value to log to the file, as a STRING
***/
function log_data($value)
{
define('LOG_FILE_PATH', 'form-data-log.txt'); // define the path to the file that you would like to have created (if it does not yet exist)
$time_stamp = date("Y-m-d H:i:s"); // get the current time
$file_pointer = fopen(LOG_FILE_PATH, 'a'); // open the log file (in 'append' mode)
fwrite($file_pointer, $time_stamp . " ---> " . $value . "\n"); // log the value to the file
fclose($data_log); // ALWAYS remember to close the log file after writing to it!
}
xxxxxxxxxx
// Enable error reporting and logging
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', '/path/to/error.log');
// Log all PHP errors
error_reporting(E_ALL);
// Your PHP code here...