How to dynamically change the file name of log file

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to dynamically change the file name of log file

Kavin Mehta
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 | Threaded
Open this post in threaded view
|

RE: How to dynamically change the file name of log file

Michael Sole-2

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:[hidden email]]
Sent: Monday, July 30, 2012 7:45 PM
To: [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: How to dynamically change the file name of log file

Kavin Mehta
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 <[hidden email]> 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:[hidden email]]
Sent: Monday, July 30, 2012 7:45 PM
To: [hidden email]
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 | Threaded
Open this post in threaded view
|

RE: How to dynamically change the file name of log file

Michael Sole-2

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:[hidden email]]
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 <[hidden email]> 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:[hidden email]]
Sent: Monday, July 30, 2012 7:45 PM
To: [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: How to dynamically change the file name of log file

Kavin Mehta
Thanks Mike!!

Now, to change it you have access to the $logConfig array in your script? so something like  $logConfig [appenders][default][layout][params][file] = 'C:\asdasd.log' should change the log file?

Pardon me if this is a silly question, but i am a noob, both in php & the logger.

Thanks,
Kavin

On Tue, Jul 31, 2012 at 12:31 PM, Michael Sole <[hidden email]> wrote:

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:[hidden email]]
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 <[hidden email]> 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:[hidden email]]
Sent: Monday, July 30, 2012 7:45 PM
To: [hidden email]
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 | Threaded
Open this post in threaded view
|

RE: How to dynamically change the file name of log file

Michael Sole-2

I think its [appenders][params][files] but its early and I haven’t finished my coffee but you get the general idea. I was the array config was a little better documented but alas I haven’t had the time to contribute.

 

From: Kavin Mehta [mailto:[hidden email]]
Sent: Tuesday, July 31, 2012 4:45 PM
To: Log4PHP User
Subject: Re: How to dynamically change the file name of log file

 

Thanks Mike!!

 

Now, to change it you have access to the $logConfig array in your script? so something like  $logConfig [appenders][default][layout][params][file] = 'C:\asdasd.log' should change the log file?

 

Pardon me if this is a silly question, but i am a noob, both in php & the logger.

 

Thanks,

Kavin

 

On Tue, Jul 31, 2012 at 12:31 PM, Michael Sole <[hidden email]> wrote:

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:[hidden email]]
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 <[hidden email]> 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:[hidden email]]
Sent: Monday, July 30, 2012 7:45 PM
To: [hidden email]
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