Log_message codeigniter

Nassim Rebhi picture Nassim Rebhi · Oct 28, 2015 · Viewed 29.9k times · Source

I want to use log_message in Codeigniter but log_message does not write anything in the log file.

$config['log_threshold'] = 4;

$config['log_path'] = 'http://spsvn01/var/www/html/RAIDLOG/application/logs/';

And in my controller I write :

log_message('error','USER_INFO '.$user_info['email']);

Thanks a lot !

Answer

Mr. ED picture Mr. ED · Oct 28, 2015

I would use the FCPATH constant which points to your application folder:

$config['log_threshold'] = 4;
$config['log_path'] = FCPATH . '/application/logs/';

Works fine on my end.

http://www.codeigniter.com/user_guide/general/errors.html

Informational Messages

log_message('info', 'USER_INFO ' . $user_info['email']);

Error Messages

log_message('error', 'USER_INFO ' . $user_info['email']);

Also, the logs folder must be writable. Do a CHMOD 700 on the folder.