Error reporting handling in Codeigniter

CodeIgniter default environment is development and so error reporting by default in turn on state, if you want to turn off reporting then change the environment value(in the top of the main index.php) to production or testing.

The above method will work with only For >= 2.x ci version. For < 2.x edit the top level index.php and adjust the error_reporting function to use E_ALL.Instead of E_ALL, you can change it to any of the predefined error constant.

Database Errors

The PHP errors are off, but any MySQL errors are still going to show. To turn these off , go to the application/config/database.php file and then Set the db_debug option to false:

So, if the error messages are hidden, how else can we tell if something is not working right? Well, CI can writes out any errors it encounters into its log file. You can configure your CI log file by going to the config.php file in your applications/config directory and set value to $config['log_threshold'] .
Note: Make your /application/logs folder writable

Threshold options are: You can enable error logging by setting a threshold over zero. The threshold determines what gets logged. Threshold options are:

0 = Disables logging, Error logging TURNED OFF
1 = Error Messages (including PHP errors)
2 = Debug Messages
3 = Informational Messages
4 = All Messages

You can also pass in an array with threshold levels to show individual error types

array(2) = Debug Messages, without Error Messages

For a live site, you’ll usually only enable Errors (1) to be logged otherwise your log files will fill up very fast.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status