Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Logging

 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I found Velocity and FOP processor were using a logging system from jakarta avalon framework.
For example, the "forumdemo" example in velocity package is using a logging system called
Jakarta Avalon Logkit logger(not sure).This logging looks nice !.
I would like to do the same for my Servlet,something like a file based runtime logging which updates all the current logging information like error,info,debug etc.,
Is it possible to do so ?
If so can anyone give me some code snippets or some links.
Regards
Balaji
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems in velocity the logging initialization is done at loadConfiguration(ServletConfig config ) method.
is it possible to do the same for servlet at some methods
 
ben munoz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can tell you how I use file based logging for my servlets. I use Log4J from http://jakarta.apache.org/log4j
There are several ways to use this package. First, import the necessary classes.

Then create a class variable for this logging object.

In your servlet's init() method, configure the logger.

In your doPost() and doGet() methods, you can send very detailed debug or error messages.

The log4j classes are well documented and easy to use. They are a valuable tool for servlet/DB developers and well worth learning.
-Ben
 
Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about the Logging API in 1.4? Do you feel it will render logging mechanisms such as log4j or the ones provided by the app servers obsolete or is there more in those mechanisms that are not covered by the 1.4 API?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic