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?
If your application is following SOA principles, for every service A you'll have the following components:
So it makes life easier to have a aController.log aService.log aExecutor.log and aPersistance.log
This is a layer based separation so all your Remoting/REST/SOAP classes will write to the aController.log
All your scheduling mechanism, backend service etc will write to aService.log
And all task executions are written to aExecutor.log and so on.
If you have a multi-threaded executor you might have to use a log accumulator or another technique to properly align log messages for multiple threads.
This way you'll always have 4 log files which is not alot and not too less, I'm telling you from experience this makes life really easier.