
A PHP application can generate different levels of errors and warnings during execution. It is important for QA engineers to see these errors in order to troubleshoot the application being tested. However, if you are having trouble displaying all the errors and warnings, you can use the following techniques to enable PHP errors and warnings.
1. Default Way
Use these lines to create logs:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/fervor.log");
error_log("Hello, errors!" );
ini_set("error_log", "/tmp/fervor.log");
error_log("Hello, errors!" );
The above code has created a log with Hello, errors! To verify, use the following command in cmd:
tail -f /tmp/fervor.log
Or
Update php.ini as described in this (Advanced PHP Error Handling via PHP)
2. Place the below-mentioned code in the index file on top:
error_reporting(E_ALL); // Error/Exception engine, always use E_ALL
ini_set('ignore_repeated_errors', TRUE); // always TRUE
ini_set('display_errors', FALSE); // Error/Exception display, FALSE in production environment or real server.TRUE in development environment
ini_set('log_errors', TRUE); // Error/Exception file logging engine.
ini_set('error_log', 'your/path/to/errors.log'); // Logging file path
error_log("Hello, errors!" );// to set your logs
ini_set('ignore_repeated_errors', TRUE); // always TRUE
ini_set('display_errors', FALSE); // Error/Exception display, FALSE in production environment or real server.TRUE in development environment
ini_set('log_errors', TRUE); // Error/Exception file logging engine.
ini_set('error_log', 'your/path/to/errors.log'); // Logging file path
error_log("Hello, errors!" );// to set your logs
Post a Comment