Logging Servlet with log4j
import javax.servlet.*; import javax.servlet.http.*; import java.io.PrintWriter; import java.io.IOException; import org.apache.log4j.*; public class LoggingServlet extends HttpServlet { private static Logger logger = Logger.getLogger(LoggingServlet.class); public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { logger.info("invoked the LoggingServlet..."); PrintWriter writer = res.getWriter(); writer.println("Check your web server console..."); writer.flush(); writer.close(); } }