View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access;
15  
16  import javax.servlet.ServletContext;
17  import javax.servlet.http.HttpServletRequest;
18  import javax.servlet.http.HttpServletResponse;
19  
20  import ch.qos.logback.core.status.StatusManager;
21  import ch.qos.logback.core.status.ViewStatusMessagesServletBase;
22  
23  public class ViewStatusMessagesServlet extends ViewStatusMessagesServletBase {
24  
25    private static final long serialVersionUID = 443878494348593337L;
26  
27    @Override
28    protected StatusManager getStatusManager(HttpServletRequest req,
29        HttpServletResponse resp) {
30  
31      ServletContext sc = getServletContext();
32      return (StatusManager) sc
33          .getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
34      
35  //    if (result != null) {
36  //      System.out.println("from ServletContext");
37  //      return result;
38  //    } else {
39  //      HttpSession httpSession = req.getSession(true);
40  //      
41  //      System.out.println("from httpSession");
42  //      return (StatusManager) httpSession
43  //          .getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
44  //    }
45    }
46  
47    @Override
48    protected String getPageTitle(HttpServletRequest req, HttpServletResponse resp) {
49      return "<h2>Status messages for logback-access</h2>\r\n";
50    }
51  }