File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Logging" Watch "Servlet Logging" New topic

Servlet Logging

Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
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.

Spritle Software Blogs
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
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

Joined: Jul 24, 2001
Posts: 5
I can tell you how I use file based logging for my servlets. I use Log4J from
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.
Panagiotis Varlagas
Ranch Hand

Joined: Nov 27, 2000
Posts: 233
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?
I agree. Here's the link:
subject: Servlet Logging
It's not a secret anymore!