neo
neo

Reputation: 2471

SLF4j - logback question: how many logger objects should you create?

I am just starting to use logback and I have a question:

Should you create one logger for each class like the following:

final static Logger logger = LoggerFactory.getLogger(className.class);

Or is that too much? maybe create a logger one per package? what is the generally considered good practice? thanks.

Upvotes: 7

Views: 461

Answers (1)

Matt
Matt

Reputation: 76

One (private one) per class - the overhead is low and you get the source information (which logger printed this) for free.

Occasionally it's worth creating an additional logger for an inner class if you want to setup your log configuration to report them at different levels.

Upvotes: 2

Related Questions