views:

109

answers:

3

Is it possible in CI (natively) to log into two different files from two different controllers? I haven't found such option in user manual nor any solution in Google.

Is there any 3rd party logging library available for CI?

+1  A: 

Is it possible in CI (natively) to log into two different files from two different controllers?

No, it isn't. Log file names are pretty much hard coded. See system/libraries/Log.php

Is there any 3rd party logging library available for CI?

That I don't know, but assuming you come empty-handed from Google, I would either ask on the CodeIgniter forums, create your own logging library, or extend the existing one. Instructions

MiseryIndex
A: 

I was looking for the same but couldn't find anything. I tweaked the code and it works fine. I have posted the same to CI forum http://codeigniter.com/forums/viewthread/139997/

Have a look it probably will serve your purpose.

shikhar
+1  A: 

You can override the Log library with your own log class, specially override function write_log($level = 'error', $msg, $php_error = FALSE). You can see the original Log library code in the file system/libraries/Log.php. To create your own Log library, overriding default behaviour, read this page.

Create the file system/application/libraries/MY_Log.php:

class MY_Log extends CI_Log {

  function MY_Log()
  {
    parent::CI_Log();
  }
  //your code
  //...
  function write_log($level = 'error', $msg, $php_error = FALSE)
  {
  //...
  }
}
Donny Kurnia