Skip to content

Instantly share code, notes, and snippets.

@azazqadir azazqadir/

Created Aug 27, 2019
What would you like to do?
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_ALL & ~E_NOTICE

For logging in individual file, add this in the file

ini_set('display_errors', 1);

ini_set('display_startup_errors', 1);


Add this statement in php.ini file to enable it

display_errors = on

Additional error logging commands

// Turn off all error reporting


// 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)


// Report all PHP errors


// 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 commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.