• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic