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?  
BrianMc1958Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrianMc1958Author Commented:
"Yes, that's bad design" would be a perfectly acceptable answer--but tell me why!
0
stevengmoreauCommented:
BrianMc1958,
Have you already implemented your solution as described? If so, what do the log4j output message look like?
0
stevengmoreauCommented:
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.

Additionally, implementing in the way you have described will not allow you to tightly control what level of output you want per class.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

cmalakarCommented:
>> "Yes, that's bad design" would be a perfectly acceptable answer--but tell me why!

You will not have much control over logging, if you go this way..
For example.. You can define, different logging levels for different packages.. which is possible normally.
0
Ajay-SinghCommented:
Its afterall not a bad design, and/or better design either.
Instead of having on log category, you should have log categories
for different component/type of system. For example, all the sql
logging should goto sql log category, all the socket logging
activity should go to netio etc.
0
BrianMc1958Author Commented:
>> 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.