I was told by somebody that the Java Logging is 90% log4j anyway, (possibly not a trustworthy source ;-> . I used log4j on a v. large project and it worked fine once we'd established the rules for its use. Based on the experience of that project though I'd suggest that briefing ALL developers on how it is to be used is essential or it becomes even more problematic than the thousands of System.out calls that we were finding before...
We also are using log4j on our project ad it is proving invaluable. It allows us to log to stdout as well as to files and it can be configured from one config file so various packages or even classes from your software are logged, not logged, logged to different files or in different formats. It seems its capable for a lot more than we are currently using it for as well. I definitely agree with briefing all developers on its use at the start of the project to avoid all the system.outs
As John said, the Java Logging is 90% log4j. So it makes no difference choosing Java Logging or log4j. The only difference is, when you use JDK1.4, you need not extra effort for getting logging API. Thanks John for your kind advice.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep
Log4J is hugely used in the industry, while Java Logging is new but ... it is the standard. as someone tells , Java Logging & Log4J are similar except for the constant of severity... the problem and there was a polemic ... is that Log4J is IBM stuff (fusionning in the Jakarta project) and Java Logging is Sun & JCP initiative. ... if I were U, I will use the standard: Java Logging which is present in JDK 1.4
Here is the original critique of the JSR 47 from log4j's point of view. http://jakarta.apache.org/log4j/docs/critique.html This is now obselete. After Subsequent changes to the JSR a revised critique was put out which highlights the remaining trivial differences between the two, http://jakarta.apache.org/log4j/docs/critique2.html If your logging needs are simple it doesn't really matter which one you use. With Log4j you will probably get new features/updates/changes/bugfixes to you much faster. With the logging API you will have to probably wait for the next iteration of the JDK from sun.
The java logging API is new in jdk1.4. Up until this I would have said that Log4J was most widely used logging API (and may still be?). I have not looked in depth at the Java Logging API but I have heard from a few sources that it is very comparable to Log4J (it seems from the other posts that others have heard similar) One reason to go with the java logging API may be that you need not keep track of the separate jars etc. Each time you move forward to new jdk you will move forward to new logging API.
I would agree, we used Log4J before JDK Logging came out, but now it just seems like an extra dependency to track and manage. Cheers, Nicholas Lesiecki
Principal Software Engineer<br />eBlox, Inc.<br />(520) 615-9345 x104<br />Check out my new book!:<br /><a href="http://www.amazon.com/exec/obidos/ASIN/047120708X/" target="_blank" rel="nofollow"><br />Java Tools for Extreme Programming: Mastering Open Source Tools, including Ant, JUnit, and Cactus<br /></a><br /><a href="http://www.rickhightower.com/JavaXPToolkit/" target="_blank" rel="nofollow">More Info</a><br /> <br /><br />Check out my article on <a href="http://www-106.ibm.com/developerworks/java/?loc=dwmain" target="_blank" rel="nofollow">AspectJ.</a>
I'm glad that Ravi Veeraghanta mentioned that log4j will likely be "refreshed" on a more regular basis than the logging API in 1.4; his point is worth considering. One further point worth considering is that log4j works with JDK 1.1 and beyond, while the new logging API is for 1.4 and beyond. Hence, if you can't adopt 1.4 for your development, log4j is an excellent tool to have in the toolbox! Keep up the great work on the Jakarta projects, team. Craig
Joined: Mar 12, 2002
Good point Craig! We're planning to switch to JDK1.4 logging where I work, but we're keeping Log4J in Cactus because of it's wider compatibility across JDKs. I wonder if Sun considered adding it as a separate jar? Cheers, Nicholas Lesiecki
Hi all, Seems u people are very experience in using log4J, I am using log4j for the first time, I have one question in mind, how to get the Logger instance, should I have to do Logger logger=Logger.getLogger(...)in each file or should I initialize it in one file and provide a bean like method to retreive the logger instance where ever in the project it is required regards Nelson
I have too made the choice between Log4j and the Logging API. I have chosen Log4j because, - Many of the systems are using JDK 1.3.1 or less - Log4j offers a lot more functionality - The configuration can be done by a xml file, which is a standard
"...you've got to ask yourself one question, Do I feel lucky?"
Hi Nelson, this in refernce to your question of making the instances of logging. That is true you have to make a instance in your every file and canot make only one instance from one common file. As while logging these instance considering the name of class where it is instantiated and appends the method name to this class name while putting it in the log. So, better and safer way is to instantiate the log in every file and then use it.
Just like you, struggeling to get the right solutions!<br /> <br />Sun Certified Java Programmer 1.5<br /> <br />Target - SCWCD
I know that this is an old thread, but I would recommend the use of Commons Logging. It's a very thin wrapper around log4j and J2SE 1.4 logging. Write your code to that API and then you can switch between the two at the flick of a switch. Here's some more detail. Simon
Joined: Sep 09, 2001
Pradeep, I have written an outline for an article that discusses Log4j and java.util.logging. I have not decided if I will finish it. -Sean
Hi Simon Can you please look at the post I made on "Other APIs" forum, here and reply? Basically I used Jakarta Commons Logging to see how it works and seems to work fine but I wanted to know if it is compatible with JDK1.2/1.3? Of course we have JDK1.4 then there is no need to ask as anyways it will use JDK1.4 logging if Log4J isn't there and in that case it will be working fine but what if we have JDK1.2/1.3 and Log4J's older version (somehow!) and we want things to work... Please reply to this post or that one and initiate "close of thread" if applicable to avoid multiple posts. Regards Maulin