Link to home
Start Free TrialLog in
Avatar of BrianMc1958
BrianMc1958

asked on

Please advise on instantiating log4j

Dear Experts,

I'm switching to log4j, like you told me to several years ago.  For my application, I know I always want all the messages going to a single log.  I'd rather not have to include the log4j library and an initialization reference to the logger in every class.  (I have a few hundred classes.)

As a workaround, I have defined a single static class (Log) that encapsulates that, and then all my other classes can just do:

Log.log.info("some message);

My question is, is that bad design?  
Avatar of BrianMc1958
BrianMc1958

ASKER

"Yes, that's bad design" would be a perfectly acceptable answer--but tell me why!
BrianMc1958,
Have you already implemented your solution as described? If so, what do the log4j output message look like?
ASKER CERTIFIED SOLUTION
Avatar of stevengmoreau
stevengmoreau

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> To clarify, I believe that by doing what you're describing the messages in your log4j output will not indicate what class created the message.

OH!  I'm brand new to log4j, and didn't realize it did that!  That's great.  Certainly answers my question.  Thanks a lot.