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]

Reply via email to