George wrote:
>
> If you've already got code that fetches a logger rather than having one
> injected, it's quite easy under Log4J to programmatically insert your
> own appender. The static getLogger() calls are just easy entry points
> into a very configurable system.
Agreed. What I like most about Freeman & Pryce's approach is that
they essentially make the logging service an interface, so instead of
doing something like:
Logger log = Logger.getLogger(MyClass.class);
log.info("Timeout waiting for database server: " + connection.getUrl());
You instead make an interface something like:
interface DatabaseLogger {
void notifyConnectionTimeout(String url);
}
So then your production code reads nicer, and you centralize your log
messages in a few logging classes as opposed to having the message
Strings all over the application.
Six of one, half a dozen of the other, though. :-) If you're testing
this stuff like it's a first-class citizen, you win either way.
Cheers,
Dan