2

I am using codeigniter logger using following configuration :

$config['log_threshold'] = 4;

These are 5 threshold used in application/config/config.php

 0 = Disables logging, Error logging TURNED OFF
   1 = Error Messages (including PHP errors)
   2 = Debug Messages
   3 = Informational Messages
   4 = All Messages

I only want to use threshold 1 and 3. If i use 4 in threshold i am able to print log message with many debug message. These debug messages will fill my server space. So i want to disable this debug mode.

I am using codeigniter version 2.2.0

Here is my log file :

  DEBUG - 2015-09-14 17:17:22 --> Config Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Hooks Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Utf8 Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> UTF-8 Support Enabled
  DEBUG - 2015-09-14 17:17:22 --> URI Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Router Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Output Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Security Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Input Class Initialized
  DEBUG - 2015-09-14 17:17:22 --> Global POST and COOKIE data sanitized

1 Answer 1

1

In CI3 you can pass array of cases/keys you want to be written. In CI2 you would need to switch places of keys in array $_levels on ln 34 of BASEPATH . 'Log.php' file or if you don't want to mess up with system files (which should be kind of good behavior) you can make extension of library:

class MY_Log extends CI_Log
{
    protected $_levels  = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');
/**
 * Constructor
 */
    public function __construct()
    {
        parent::__construct();
    }
}

I believe this way it should work too.

Sign up to request clarification or add additional context in comments.

9 Comments

I switch the places of keys in my existing system/libraries/Log.php and i use $config['log_threshold'] = array(3, 1); It did not solve my problem.
If you have set array like in example I showed, try with $config['log_threshold'] = 2;
Thanks. It works for me. I am seeing following error message : ERROR - 2015-09-23 17:52:11 --> Severity: 8192 --> mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead If i change my db driver name to mysqli , All mysql fuctions stop working please suggest how can i remove this error message from loggers
How do you mean: you want only info shown in log, not errors?
Actually i need both error and info message but i want to remove this message from loggers : ERROR - 2015-09-23 17:52:11 --> Severity: 8192 --> mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
|

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.