Essentially I'm looking for something with the same behavior, configuration, logging levels as log4j, but with some of the missing functionality (e.g. formatted logging — see here and here for related SO threads.)
Asked
Active
Viewed 1,580 times
4
-
Innocent question, what's wrong with: logger.info(String.format("id = %d, value = %s", id, value)); :) – OscarRyz Jul 07 '09 at 23:25
-
String.format() is processed even if the logging level is not at the info level. – RealHowTo Jul 08 '09 at 02:11
-
2There are 3 reaosons I don't like it: There's a performance penalty, the code is uglier, and the solution is really easy. – ripper234 Jul 08 '09 at 05:21
3 Answers
12
I'm inclined toward SLF4J.
- allows parameterized logging (formatting)
- allows consolidation of other frameworks (great for apps using many libraries, each logging to a different framework)
log5j is good, but does not have near as much market penetration.

Chadwick
- 12,555
- 7
- 49
- 66
-
I'm inclined to agree, especially as there is a slf4j implementation to replace commons-logging. – Gareth Davis Jun 09 '09 at 09:52
3
since a lot of frameworks already support slf4j you will only have to setup your logging once with slf4j.
i use slf4j and it is super-easy to read + use.

Andreas Petersson
- 16,248
- 11
- 59
- 91
3
I'd also suggest SLF4J, ideally with Logback. Take a look at What’s Up with Logging in Java? and Find a way in the java logging frameworks scene., too.