How to save error logs in file in Codeigniter 3

Hello World, Welcome to Today I am going to discuss how to save error logs in the file in Codeigniter 3. Sometimes we need to save the errors in our development process. We can do this with a very easy step.

  • Open application/config.php
| Error Logging Threshold
| 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 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.
$config['log_threshold'] = 1;

You can change the above threshold according to the requirements. They have defined all options.

It will save the error in the application/logs directory.

Make sure your logs directory has writable permission

Leave a Reply