FileDocCategorySizeDatePackage
LoggerNewConfig.javaAPI DocExample1384Thu Jul 10 16:15:52 BST 2003com.jspservletcookbook

LoggerNewConfig

public class LoggerNewConfig extends HttpServlet

Fields Summary
private Logger
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 some HTML
      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 a Logger with its own configuration in the log4j.properties file</h2>");
      out.println("Your logger name is: " + log.getName()+"<br>");
      out.println(
        "Your logger parent is: " + log.getParent().getName()+"<br>");
      out.println("</body></html>");
      out.close();
     
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        
        doGet(request,response);
    
public voidinit()


    
  
      log = Logger.getLogger(LoggerNewConfig.class);
      
      log.info("LoggerNewConfig started.");