PHP CodeIgniter Error Log Not working properly

10,967

Solution 1

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

Solution 2

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.

Solution 3

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

Share:
10,967
Demo User
Author by

Demo User

Updated on June 15, 2022

Comments

  • Demo User
    Demo User almost 2 years

    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. )