I decided to use Log4J logging framework for a new Java project. I am wondering what strategy should I use for creating/managing Logger instances and why?
one instance of Logger per class e.g.
class Foo { private static final Logger log = Logger.getLogger( Foo.class ); }
one instance of Logger per thread
- one instance of Logger per application
- horizontal slicing : one instance of Logger in each layer of an application (e.g. the view layer, the controller layer and the persistence layer)
- vertical slicing : one instance of Logger within functional partitions of the application
Note: This issue is already considered to some extent in these articles: