In our project we are using
logback for our logging.
One really nice feature is that you don't need to do the whole
if (logger.isDebugEnabled()) {
logger.debug("hi there " + person + ".");
}
You can simply do:
logger.debug("Hi there {}.", person);
A nice, and obvious use of
variable argument lists (introduced in JDK 5.0).
OK, arguably publicising logback is reason enough for a post, but the real reason I am posting is to point out something that might catch other developers who don't have time to read the entire manual :)
Logback has it's own configuration, but if you manage to get it wrong, and it cannot find that configuration it uses it's own default. This default configuration (from the manual):
is hardwired to attaching a ConsoleAppender to the root logger. The output is formatted using a PatternLayout set to the pattern %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n. Moreover, by default the root logger is assigned to the DEBUG level.
So, if you start using it and wonder why you get a whole load of debug, now you know. In fact, you know at least two things:
- Logback isn't picking up your configuration (which you might not have)
- You need to read the manual, in particular the section on configuration
Go on, be honest, how many people are going to simply read the configuration section and skip the rest, or even better - how many are going to google-paste (google for a configuration and copy and paste it into your own code :)). You know who you are!
No comments:
Post a Comment