5

I've 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 Index.php file-

case 'development':
error_reporting(E_ALL);
break;

case 'testing':
case 'production':
     error_reporting(0);

When it's "development" in Index.php, i see warnings, and error messages also on webpage, PHP Fatal error, PHP Parse error in php_errors.log file. But if I make it "Production", no error/warnings are not displayed nor logged in the file. How do I log all errors and messages without displaying?

(Just to mention here- The folder application/logs/ is 777 and there all I have is index.html that has "403 Forbidden" written in it. )

4
  • Is there some over writing of configurations happening? Commented Aug 9, 2012 at 16:46
  • Have you tried leaving the log_path as the default ''? Commented Aug 9, 2012 at 19:27
  • Yes, I tried. But nothing is happening. I even tried full log path- 'home/theuser/path/to/log/' It's just not working... Do you have any idea of what might be reason? Commented Aug 9, 2012 at 23:56
  • Have you looked at your error.log to see if it throws any errors? Commented Aug 10, 2012 at 3:44

3 Answers 3

8

Please 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
Sign up to request clarification or add additional context in comments.

Comments

1

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

error_reporting in php settings shows you errors created during php script execution. If you use "desplay_errors" = Off. PHP won't show any of those errors. You have turned on log_errors and setup a folder. So PHP error will get to the /var/log/php_errors.log file.

On the other hand CodeIgniter uses function:

log_message('level,'message')

which serves for storing errors/debug/info into 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 log directory.

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

Try calling your own log_message and turn display_errors to On. I think that it should help.

Comments

1

You have to set error_reporting(E_ALL); under case 'production' in your index.php file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.