How to Log
While you can use full-blown logging solutions such as Java's logging facilities and log4j in servlets, the Servlet API offers a very simple but convenient way of logging. The methods log(String) and log(String,Throwable) in ServletContext allow you to add a line to the server's event log, optionally with an Exception as second argument. For convenience, HttpServlet (and its super-class GenericServlet) also provides you with two identical log methods that call the implementations in ServletContext. So in order to log something in a HttpServlet sub-class you only need to write this:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
log("I am in the log!");
// ...
}

