Originally titled: How can I get Apache LogFactory to always return the same log implementation?
I have a project that uses quite a few different loggers configured to go to different places. When I'm running a unit test, I want to override them all with a SimpleLogger that I instantiate myself. How can I set this into LogFactory so that it's always returned for unit tests?
I'd really rather not deal with an external configuration file.
As a little bit of background, I find loggers notorously untrustworthy. It's not really the logger exactly, it's that there are so many ways to configure it and filter the output--it can be done from various config files or anywhere in code, and then it could go out to a variety of locations. The logger can even send some kind of output (errors) to different locations from others based on the configuration.
Although this can be quite awesome and powerful, it's all undone when you spend 6 hours wondering why your code isn't being called when it actually IS being called but your output is being redirected.
When running tests I want to be as sure as possible that I'm seeing all the output, so I want to redirect ALL logs to the console. (All, as in my current project can create a couple dozen different logfiles spread across 6 directories.)