log file in Codeigniter

2019-09-08 05:46发布

问题:

I need to create a error log file in codeigniter. As per the rules i changed the value $config['log_threshold'] = 1; in config.php file. Error log file was created in the logs folder. But i wrongly deleted that file. I wrote the coding like this

 $data['name'] = "Somename";
 $add_department = $this->db->insert('mas_factory',$data);
 if($add_department == false)
 { 
     log_message('error', 'Table field name is wrong.');    
 }

error log file is not automatically generated. But i need to see the error messages in error log file. How to create a log file.

回答1:

Make your /application/logs folder writable

In /application/config/config.php set

$config['log_threshold'] = 1;

Use log_message('error', 'Some variable did not contain a value.');

If you deleted the file simply re upload..`