Single Log Files

#1
[eluser]Madalina.C[/eluser]
Hi, I'll try not to sound like a girl in distress but here goes:

In it's current incarnation, CI creates a new log file everyday.

Our system already has an archiving feature for log files so I would like to keep all logs in one file. This file will be moved/archived from our side.

I was thinking about simply taking:

Code:
$config['log_date_format'] = 'Y-m-d H:i:s';

and changing it to

Code:
$config['log_date_format'] = 'McmaxxSite';

Would that create a file called
Code:
log-McmaxxSite.php

Which the logger will append to everyday, or will it overwrite the file everyday?

Thanks

#2
[eluser]danmontgomery[/eluser]
log_date_format applies to the date format each logged message uses, not the naming of the file.

The file is named in system/libraries/Log.php, you could extend this class to change the naming behavior.

#3
[eluser]Madalina.C[/eluser]
Noctrum

Thanks for the quick reply!

I'll post my new code later on for other people to use

#4
[eluser]Madalina.C[/eluser]
Here is the steps to take to make it one file.

Take
Code:
system/libraries/Log.php

and copy it to

Code:
system/application/libraries

Replace the line
Code:
$filepath = $this->log_path.'log-'.date('Y-m-d').EXT;

With

Code:
$config =& get_config();
$filepath = $this->log_path.'log-CI-'.str_replace(array("http://","/"),"",$config['base_url']).EXT;
(You can change the middle str_replace part with whatever you want, I just removed slashes and unnecessary characters)

It now creates the file
Code:
log-CI-some-site.php

Be sure to have some system in place to clear/move it or it might esplode in size


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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