How to do error logging in CodeIgniter (PHP)

Better Stack Team
Updated on November 23, 2022

Code igniter has logging capabilities built-in. Make sure you do the following:

  • Make your /application/logs folder writable
  • In /application/config/config.php set the following:
$config['log_threshold'] = 1;
  • Use the following syntax to log a message:
log_message('error', 'Some variable did not contain a value.');
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →