This is what I am using now:
//Logging config
        $logConfig = array(
                    'appenders' => array(
                        'default' => array(
                            'class' => 'LoggerAppenderRollingFile',
                            'layout' => array(
                                'class' => 'LoggerLayoutTTCC',
                            ),
                            'params' => array(
                                'file' => BASE_APP_PATH.'log/'.$db.'.log',
                                'maxFileSize' => '1MB',
                                'maxBackupIndex' => 5,
                            ),
                        ),
                    ),
                    'rootLogger' => array(
                        'level'=>'WARN',
                        'appenders' => array('default'),
                    ),
                );

        Logger::configure($logConfig);
        $log = Logger::getLogger('myLogger');

From: Kavin Mehta [mailto:kavinme...@gmail.com]
Sent: Tuesday, July 31, 2012 1:03 PM
To: Log4PHP User
Subject: Re: How to dynamically change the file name of log file

Thanks Mike. Appreciate the quick response.

Can you give me an example?

Thanks,
Kavin Mehta.

On Tue, Jul 31, 2012 at 6:13 AM, Michael Sole 
<ms...@gold-mobile.com<mailto:ms...@gold-mobile.com>> wrote:
Kavin,

If you use the array config method you can set the file dynamically. This is 
what I am doing.

Mike

From: Kavin Mehta [mailto:kavinme...@gmail.com<mailto:kavinme...@gmail.com>]
Sent: Monday, July 30, 2012 7:45 PM
To: log4php-user@logging.apache.org<mailto:log4php-user@logging.apache.org>
Subject: How to dynamically change the file name of log file

Hi,

I am using a relative path for the name of the log file in my appender. I am 
using <param name="file" value="../admin/logging/log4php.log" />. I find this 
more helpful then an absolute path, because our developers work across 
different OS systems. I was wondering if there is a way to change this setting 
dynamically or may give it some variable name?

Thanks,
NooB

Reply via email to