Thursday, March 4, 2010

PHP log errors to log file

Logging PHP errors to a log file is critical. You don't want to display PHP errors or warnings to users, but to log all errors to a file that you can view. This way you can fix all errors, warnings, notices and the client won't see any PHP error.

You can easily do this by adding two lines at the beginning of your code:

ini_set('log_errors', 1);
ini_set('error_log', '/path-to/error_log.file');

You can use later any editor to view contents of your log file and fix all problems that occured.

No comments: