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?
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?
BrianMc1958,
Have you already implemented your solution as described? If so, what do the log4j output message look like?
Have you already implemented your solution as described? If so, what do the log4j output message look like?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>> 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.
OH! I'm brand new to log4j, and didn't realize it did that! That's great. Certainly answers my question. Thanks a lot.
ASKER