CodeIgniter Forums
How to do error logging in CodeIgniter (PHP) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How to do error logging in CodeIgniter (PHP) (/showthread.php?tid=84599)



How to do error logging in CodeIgniter (PHP) - mayhutam - 10-25-2022

I want error logging in PHP CodeIgniter. How do I enable error logging?

I have some questions:
  • What are all the steps to log an error?
  • How is an error log file created?
  • How to push the error message into log file (whenever an error occurs)?
  • How do you e-mail that error to an email address?



RE: How to do error logging in CodeIgniter (PHP) - InsiteFX - 10-26-2022

Please read:

CodeIgniter 4 User Guide - Error Handling


RE: How to do error logging in CodeIgniter (PHP) - kenjis - 10-26-2022

See https://codeigniter4.github.io/CodeIgniter4/general/logging.html


RE: How to do error logging in CodeIgniter (PHP) - DunogRamers - 11-04-2022

CodeIgniter has some error logging functions built in.

Make your /application/logs folder writable
In /application/config/config.php set
$config['log_threshold'] = 1;
or use a higher number, depending on how much detail you want in your logs
Use log_message('error', 'Some variable did not contain a value.');
To send an email you need to extend the core CI_Exceptions class method log_exceptions(). You can do this yourself or use this. More info on extending the core here