Which Logging package?
OK, for the Java experts amongst you...
Are there good reasons for using log4j rather than the Java 1.4 (and higher) Logging package?
Herr Herr
Tuesday, May 25, 2004
I don't know but I second the question.
name withheld out of cowardice
Tuesday, May 25, 2004
My current project I am using the logging features in 1.4. I wanted to something a little simpler than log4j. But log4j is nice because all the work is done for you. Both are good and one is not better in all circumstances.
Bill Rushmore
Tuesday, May 25, 2004
From my limited experience, JDK 1.4 logging has the advantage of not requiring an additional JAR file which is nice during deployment. log4j allows you to roll log files based on date (which I don't think java.util.logging does), which is also nice. Both are configurable and can probably be made to do what you want, if needed. log4j also has the advantage that if you are using existing packages that have logging they are more likely to already use log4j than java.util.logging.
To summarize my opinions, if you are integrating with existing code which uses logging, stay with the logging that is already in use. If you are starting from scratch, I would use java.util.logging to reduce external dependencies, unless log4j has some feature that you just must have and java.util.logging doesn't provide it built in.
madking
Tuesday, May 25, 2004
The source of this question, that Java didn't have a logging package until its fifth major release, proves Gosling and his team of amateurs had no experience delivering application software. (Although to be fair to Gosling, he didn't work on Java during the third and fourth release, nor perhaps the second, so there's plenty of blame to go around at Sun.)
!gosling
Tuesday, May 25, 2004
Pre-1.4 compatibility
A lot more appenders by default inclusing NT events, UNIX syslogs, JMS messages, databases, etc.
Asyncronous logging capabilites.
More java products i've used use log4j rather than the java logging.
I used the Java 1.4 logging on a small scale in a previous project and it was useful, but i've found log4j much more powerful to use. We have an application server installation (JBoss which uses log4j) and a client installation that both use log4j and we have no regrets.
You can even configure it to dynamically watch your configuration file (which can be plain text or XML) and adjust the logging at runtime if you make change.
Overall I'd recommend log4j. I'm not sure what changes JDK 1.5 will bring to logging, but I haven't read about any. They certainly aren't promoting it as much as generics and enums.
Finally you may also want to check out the Jakarta Commons Logging project. Supposedly it is a common interface that can use different logging pakages underneath. That's all i know, so i'm not sure if it's simpler or not.
Matt Lee
Tuesday, May 25, 2004
Jakarta Commons Logging is a wrapper that can be used around Log4J or JDK 1.4 logging or possibly some other logging packages. You write your code to use the commons-logging API and then the system finds an appropriate implementation. If you want to see code, at least some of the other Apache Java projects (Struts, some of the Jakarta projects) use it.
The lead developer of Log4J wrote an article about the relative merits of commons-logging, JDK 1.4 logging and Log4J: http://www.qos.ch/logging/thinkAgain.html
Beth
Tuesday, May 25, 2004
Log4J is much easier to use - Java 1.4 Logging is so much more difficult to work with.
Hani summarises things nicely: http://www.jroller.com/page/fate/20031018
Walter Rumsby
Tuesday, May 25, 2004
I am the Original Poster
Thanks all for the info.
Based on my own experience on past projects with log4j and your combined advice, I think will use log4j this time.
What do I love about my career? These days I get to make the decisions about which technologies and architectures to use. And which logging packages.
Herr Herr
Wednesday, May 26, 2004
Recent Topics
Fog Creek Home
|