PHP offers simple but effective solution to log all errors to a log fiie. On all production web server its a must that you turn off displaying error to end users via a web browser. Remember PHP gives out lots of information about path, database schema and all other sort of sensitive information. You are strongly advised to use error logging in place of error displaying on production web sites. The idea is quite simple -only developer should see php error log.
The way I choose to do it is by having a common config.php file containing this code and included in the first line of every page.
1 2 3 4 5 6 7 8
// Display no errors in runtime pages ini_set("display_errors" , "0"); // Log errors to file ini_set("log_errors" , "1"); // Error log file path and name ini_set("error_log" , "logs/Errors.log.txt");
Latest posts by Abhishek Gupta (see all)
- Laravel Custom Exception Handlers - March 28, 2019
- Customizing Laravel validation JSON message format - March 20, 2019
- Time killer and addictive Google Games - March 19, 2019