views:

89

answers:

4

Hello Everyone

I am at the point for my little test-webapplication that I need some logging. I have no real experience in log4j nor java.util.logging and I was thinking if I should start right away with a logging facade (slf4j).

I was reading that a logging facade should be used for libraries that are shared (frameworks) which makes sense. But in case if a particular application I am not sure where to go. Would it be better to use log4j (or logback) directly due to performance? Or should I start with slf4j right away since I dont know the others anyway?

Thanks

+1  A: 

For a standalone application I would start with Jakarta Commons Logging together with log4j.

rsp
A: 

SLF4J was created as an improvement to log4j, issues addressed include performance and, i think the most beneficial, the ability to plug in a logging framework at deployment time.

I suggest you start with the first, log4j, its very simple and will make understanding SJF4J easier as well.

n002213f
A: 

I don't recommand java.util.logging, as finding a configuration mistake with it is a nightmare. The best choices are:

  • log4j for backend
  • commons-logging (more popular) or slf4j (more recent) for frontend
Kartoch
+1  A: 

Log4j, Java Logging are logging frameworks (A)

SLF4J, Commons-Logging are logging-facade frameworks (B)

www.slf4j.org/faq.html#when

Even when you use anything in list (B) above you still need to give it an underlying actual logger implementation (which is something from list A) for it to work properly.

So if you are doing a library which you will ship to someone (and you don't know which of the frameworks they will use from list A) THEN you should go for something in list B (SLF4J being the ideal)

If you are doing a standalone app then in all probability log4j (from list A) should solve your purpose.

Calm Storm
Thanks.I started to try out logback, since it is supposed to be the successor of log4j (same author). The tutorials I used by now make use of the slf4j packages because this is directly integrated in logback (so no additional dependencies).
lostiniceland