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?
The strategy that is most used is to create a logger per class. If you create new threads give them a usefull name, so their logging is easily distinguishable.
Creating loggers per class has the benefit of being able to switch on/off logging in the package structure of your classes:
log4j.logger.org.apache = INFO
log4j.logger.com.example = DEBUG
log4j.logger.com.example.verbose = ERROR
The above would set all apache library code to INFO level, switch logging from your own code to DEBUG level with the exception of the verbose package.