CodeIgniter Forums
Writing to File in log directory from custom library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Writing to File in log directory from custom library (/showthread.php?tid=41238)



Writing to File in log directory from custom library - El Forum - 05-02-2011

[eluser]NotoriousWebmaster[/eluser]
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,
- AAA


Writing to File in log directory from custom library - El Forum - 05-02-2011

[eluser]bubbafoley[/eluser]
is this what you are looking for?

Code:
$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');
fclose($fp);



Writing to File in log directory from custom library - El Forum - 05-03-2011

[eluser]NotoriousWebmaster[/eluser]
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:

Code:
$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 )