PHP CodeIgniter Error Log Does Not Work Properly

I have the following settings in php.ini -

error_reporting = E_ALL | E_NOTICE | E_STRICT|E_WARNING display_errors = Off log_errors = On error_log = "/var/log/php_errors.log" 

And config.php in CodeIgniter -

 $config['log_threshold'] = 1; $config['log_path'] = getcwd() . '/' . SYSDIR . '/logs/'; 

In the file Index.php -

 case 'development': error_reporting(E_ALL); break; case 'testing': case 'production': error_reporting(0); 

When it "develops" in Index.php, I see warnings and error messages also on the web page, PHP Fatal error, PHP Parse error in the php_errors.log file. But if I do this "Production", no errors / warnings are displayed and are not recorded in the file. How can I log all errors and messages without displaying?

(Just to mention here: the application / logs / 777, and there all I have is index.html, which says "403 Forbidden".)

+4
source share
3 answers

Check your config / config.php file and check your settings

 $config['log_threshold'] = 4; **Note :** 0 = Disables logging, Error logging TURNED OFF 1 = Error Messages (including PHP errors) 2 = Debug Messages 3 = Informational Messages 4 = All Messages 
+4
source

I'm not quite sure, but I think you are mixing two things together.

error_reporting in php settings displays errors created at runtime by PHP script. If you use "desplay_errors" = Off. PHP will not show any of these errors. You turned on log_errors and set the folder. Thus, the PHP error will fall into the file / var / log / php _errors.log.

CodeIgniter, on the other hand, uses the function:

 log_message('level,'message') 

which is used to store errors / debug / info in the log files. If you call

 log_message('error','I'm an error!') 

somewhere in your code, you really should have a new log file in the log directory.

Internaly CodeIgniter uses log_message () if there are PHP errors. I'm really not sure how it will behave as long as display_error is set to Off (will it think there was no error?).

Try calling your own log_message and turn display_errors on . I think this should help.

+1
source

You must set error_reporting (E_ALL); in case of "production" in your index.php file

0
source

All Articles