z9rusa
Last Updated: August 27, 2019
·
227
· oliverusselldev

Commands Used in Error Logging in PHP

To enable error logging, open php.ini file and add this

error_reporting = E_ALL & ~E_NOTICE

error_reporting = E_ALL & ~E_NOTICE | E_STRICT

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ER… _ERROR

error_reporting = E_ALL & ~E_NOTICE

For logging in individual file, add this in the file

ini_set('display_errors', 1);

ini_set('display_startup_errors', 1);

error_reporting(E_ALL);

Add this statement in php.ini file to enable it

display_errors = on

Additional error logging commands

// Turn off all error reporting

error_reporting(0);

// Report simple running errors

error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized variables or catch variable name misspellings ...)

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE

error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)

error_reporting(E_ALL);

// Report all PHP errors

error_reporting(-1);

// Same as error_reporting(E_ALL);

ini_set('error_reporting', E_ALL);

To check PHP error log location, use this command:
<?php phpinfo(); ?>

To store logs in a different file than default one, add this to php.ini
error_log = /var/log/php-scripts.log

Source: PHP error logging guide