Search code examples
phpcodeignitererror-logging

Logs aren't showing in logs folder in codeigniter 3


I'm attempting to add logging into my CI project. I have added the Error Logging Threshold in config as $config['log_threshold'] = 2; and kept the log path empty $config['log_path'] = ''; I'm writing the logging in my controller as

    $product = $this->Pizza_Model->find_pizza($id);
        if ($product == '')
    {
        log_message('error', 'Pizza is not fetched from database');
    }
    else
    {
        log_message('debug', 'Pizza was fetched'.print_r($product,TRUE));
    }

When i run my application nothing is written on the logs folder. Do i have to specifically give the log path in the config file for logs to be written? if so how can i give the log path in the config file?


Solution

  • $config['log_path'] is supposed to be a path to a directory, not a file. Try a path to a directory, and make sure to include a trailing slash.

    Also try 755 (or 777 be careful) permissions on directory if it still doesn't work.

    EX. $config['log_path'] = '/var/log/ci_logs/';