aspose file tools*
The moose likes Struts and the fly likes Which log() to use? JDK, Servlet, or log4j? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Which log() to use? JDK, Servlet, or log4j?" Watch "Which log() to use? JDK, Servlet, or log4j?" New topic
Author

Which log() to use? JDK, Servlet, or log4j?

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
GenericServlet and ServletContext classes have log() method;
JDK 1.4 now have Logger APIs.
And we have log4j.
Which one of the above should be used? Is log4j out of date in servlet?
Thanks.


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
I haven't looked into the JDK 1.4 logging features in depth, but they are more powerful that the log method in the GenericServlet class. I guess it depends on what you are trying to do. The GenericServlet class is going to be the easiest to use since there is no class importing to worry about. If I were using JDK 1.4 I would probably choose that over log4j since it is part of the standard java package.


Matthew Phillips
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
Thanks Matthew.
JDK 1.4 logger API is really nice. I was just wandering if log4j has something special.
If not people may just forget about it and use JDK logger API.
timothy zimmerman
Ranch Hand

Joined: Jun 26, 2001
Posts: 149
I think the jdk1.4 logging api is very similar to log4j. I have worked a bit with log4j but have only browsed the jdk api so I cannot give a definitive answer but they do seem very similar and I cannot off the top of my head think of something log4j offers that is not in jdk1.4.
[ August 06, 2002: Message edited by: timothy zimmerman ]
Steve Loughran
Ranch Hand

Joined: Aug 06, 2002
Posts: 37
I use jakarta commons logging in all my lowlevel stuff so they can be reused everywhere; I tend to use log4j as my default logging system on top of this.
Steve Loughran
Ranch Hand

Joined: Aug 06, 2002
Posts: 37
Originally posted by timothy zimmerman:
I cannot off the top of my head think of something log4j offers that is not in jdk1.4.
[ August 06, 2002: Message edited by: timothy zimmerman ]

Logging to NT event logs, Chainsaw to merge logs from servers in a cluster into one place, ability to specify rolling logs that get replaced every hour, fancy html output, etc. All at the price of configuration file effort.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which log() to use? JDK, Servlet, or log4j?