If you can set a system property then you can use that to set the filename. You still may want to use the config file and just have code change the appender filename.
On 7/30/06, Eshwaramoorthy Babu <[EMAIL PROTECTED]> wrote:
James/Javier, Thanks for your help. I can not use the static config file because my requirement is to set the log file name at runtime. I do not see any other approach other than setting the appender in the code. I have use your 1st approach(static block). Thanks again, Babu On 7/29/06, Javier Gonzalez <[EMAIL PROTECTED]> wrote: > > On 7/29/06, Eshwaramoorthy Babu <[EMAIL PROTECTED]> wrote: > > James you are right. I am doing 'new' every time. Can you please tell me > why > > this is happening. Because I am calling the log method in the current > > instance. > > Loggers are static objects. Each time you call new on your class, you > are creating a new Appender instance and attaching it to the same root > logger, so you get n appenders (n = number of times you have called > new on your wrapper) processing every message that is sent to the root > logger, which results in n duplicates. > > To fix this, I can see two alternatives: > > 1.- Use a static block to create and initialize the appender so that > only one gets created at class loading instead of a new appender for > every instance, or... > 2.- ...use a configuration file to define the appender. > > I prefer #2 - it's cleaner, you can modify your logging configuration > without having to edit code. The way you have it right now, even > changing the date format in the log messages implies that you have to > edit code, recompile and redeploy your app. > > Cheers, > > -- > Javier González Nicolini > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
-- James Stauffer Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
