Reputation: 31
I am writing API that I need to pass to the next developer as a jar file that he/she will use in his program. What is the nice way to write debugg code inside API that will be controlled by the code that is using it.
Thanks a lot.
Upvotes: 0
Views: 158
Reputation: 36611
If you just ship a JAR, it would be so nice to not depend on log4j in the first place, but let users of your plug in their own "LoggerFactory". All the "Loggers" you obtain in your code are obtained through that factory the same way as you would retrieve them from log4j (e.g. by passing the class name), and should have similar levels.
That way customers who want to use log4j still can, and customers who use another logger can plug it in in a jiffy.
Upvotes: 0
Reputation: 8295
I think you are talking about debugging log? use log4j:
if (log.isDebugEnabled()) {
log.debug("xxxxxxxxxxxxxxxxxxxxxxx");
}
UPDATE: log4j can configure the log level
for a specific class: put the following in log4j.properties
log4j.logger.com.test.Test=DEBUG
Upvotes: 0
Reputation: 160191
Upvotes: 2