FileDocCategorySizeDatePackage
LoggerCLServlet.javaAPI DocExample1500Mon Sep 08 10:15:46 BST 2003com.jspservletcookbook

LoggerCLServlet

public class LoggerCLServlet extends HttpServlet

Fields Summary
private Log
log
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

    
    //display a DEBUG level message
    log.debug("Sending a DEBUG message");
    //display an INFO level message
    log.info("Sending an INFO message");
    
    //better display something
      response.setContentType("text/html");
      java.io.PrintWriter out = response.getWriter();
      out.println("<html><head><title>Servlet logging</title></head><body>");
      out.println("<h2>Hello from LoggerCLServlet: " + log.getClass().getName() + "</h2>");
      out.println("Is the log info enabled? " + log.isInfoEnabled() +"<br>");
	  out.println("Is the log debug enabled?" + log.isDebugEnabled()+"<br>");
      out.println("</body></html>");
      out.close();
     
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        
        doGet(request,response);
    
public voidinit()


    
  
  //System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.Log4JLogger");
	  
  log = LogFactory.getLog(LoggerCLServlet.class);
  log.info("LoggerCLServlet started.");