tags:

views:

20

answers:

2

log4j or java.util's logger which is the best to use .. already this question is thr but i did get clear idea..

can any one help me out ...

A: 

I doubt that there will be consensus on this, both get the job done. The real answer is of course "it depends ...", the idea of "best" depends so heavily on your particular requirements.

I take the following thought process:

  1. Look at your target environment. Does it have useful support for one or the other? For example WebSphere has integrated support for java.util.logging, you can set trace strings through the console and WebSphere itself uses java.util.logging. So that often drives me to java.util.logging.
  2. Look at the common practive in your environment. Is there history and competence with one or the other? If all other apps in your environment use, say, log4j then it's probably best not to swim against the tide.
  3. Do you have special requirements? For example logging to a central message queue. Are there off-the-shelf extensions to either package that meet your needs?

My perception is that log4j is more widely used and hence I'd expect item 2 above to lead more often to log4j.

Personally, so long as logging is being done intelligently I don't much care what package is used. Anything beats System.out.println().

djna
A: 

IMO, the only real advantage of java.util.logging is that it is present in all Java SE platforms (since Java 1.4).

Log4j is more flexible and easier to configure using configuration files. I think I've heard claims that it is faster too ... but I cannot cite any sources.

Stephen C