This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Looks like what Dotcms uses. I'm not sure about the performance though. How do you resolve the logger for the passed instance? Look it up each and every time? If you do a lot of logging, that's going to have a (small) performance hit. I'd rather have one single static variable (which I personally have a template for to create quickly) than suffer lookups per call.
Also, how do you handle errors in combination with formatted messages? For example, how to do it with SLF4J:
The exception is then logged after the message, which includes the file. How does your code handle situations like this?
Joined: Feb 11, 2011
Yes, we're calling LoggerFactory.getLogger(object.getClass()) every time we need a logger.
We don't support exception logging the way it works with slf4j. However, we support "decors", which help you to render exception's stacktrace (your example):
We're using the same formatting as in String.format(), which is much more powerful than markers in slf4j.