• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing to File in log directory from custom library

Hi all:

Just learning CI on a legacy system.

I'm interested in porting my log class to CI as a library. How do I specify writing to a file in the log directory?

Thanks for your help,

is this what you are looking for?

$ci = get_instance();
$log_path = ($ci->config->item('log_path') != '') ? $ci->config->item('log_path') : APPPATH.'logs/';
$fp = fopen($log_path.'custom_log.php', FOPEN_WRITE_CREATE);
fwrite($fp, 'your log message here');

Update: Let's hold off on this. I took out references to Aalog, and still got the error. So it's outside of my code... News at 11.

Thanks bubbafoley, it may very well be; but I can't even get to my library. Here's the code I have in the controller:

$this->load->library('aalog', array('logName' => 'ccsr.log'));

And here's the error I get:

Quote:Fatal error: Class 'CI_Log' not found in C:\_sites\ccsr\system\codeigniter\Common.php on line 148

I have a file called Aalog.php in system\application\libraries. (This is also a source of concern for me: isn't application supposed to be outside of system; a sibling in fact?)

Thanks again for your help. (Looking forward to shedding my Summer Student status. Wink )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.