I am a bit new to the Web CodeIgniter 3.0 Framework.
I have more experience in Java web programming, and when executing a query to the database used and that mapped the log4j log each query to the database.
Is there any plugin or library for consultation and future errors in the database? (for PHP using the CodeIgniter 3.0 Framework).
You can log any errors to system log with function log_message
Also you can set log level in your application/config/config.php
here is the sample settings:
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages|
*/
$config['log_threshold'] = 2;
$config['log_path'] = '';
$config['log_date_format'] = 'Y-m-d H:i:s';
If you want to use custom message for sql queries:
if ($this->db->simple_query('YOUR QUERY'))
{
echo "Success!";
}
else
{
log_message('debug', 'sql query fail in... ', false);
}
Go to the application/config folder and open config.php
If you set
$config['log_threshold'] = 1;
It will log all error messages including PHP errors.
The options for this setting 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 edit the line:
$config['log_path'] = '';
To save the error log in a directory of your choice, but leaving it like this will capture the error logs in the application/logs directory. It will create a new separate log file for you for each day an error is encountered.
You can also use Codeigniter's log_message function to capture errors in specific circumstances. More information here
https://ellislab.com/codeigniter/user-guide/general/errors.html
CodeIgniter already has his own logs, by default you will find them in application/logs
. You can change the path application/config/config.php