logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Javier Gonzalez" <jagon...@gmail.com>
Subject Re: Best practice on declaring Loggers
Date Tue, 13 Jun 2006 14:43:02 GMT
On 6/13/06, Joshua.P.Williams@alltel.com <Joshua.P.Williams@alltel.com> wrote:
> I'm new to JAVA and log4j, but I created a singleton object to be my logger that is used
by all the classes in a single threaded project I'm working on.. Is this bad?  I suppose I
didn't know how to use the log4j api correctly, but I was getting duplicate records in my
logs, so I created a singleton object that every other object uses and it solved my problem
(no more duplicate entries in my logs).

Hi!

While your approach works, it isn't the ideal way - using a single
logger will hinder you if you need to split logs, sort them by
component, etc.

With regards to your duplicate logging problem, I'll bet you added the
same appender to both the root logger and your app logger.

(search in the mailing list archives, the duplicate logging problem
has been addressed multiple times :)

-- 
Javier González Nicolini

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message