Answers for "How to Log Errors to a Text File with PHP"

PHP
1

php set error log file

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
Posted by: Guest on July-31-2021
2

php store log in a text file

$log_content="This line is logged on 2020-08-14 09:55:00";
$myfile = fopen("log.txt", "a") or die("Unable to open file!");
fwrite($myfile, $log_content);
fclose($myfile);
Posted by: Guest on August-14-2020

Browse Popular Code Answers by Language