001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.access;
015
016import javax.servlet.ServletContext;
017import javax.servlet.http.HttpServletRequest;
018import javax.servlet.http.HttpServletResponse;
019
020import ch.qos.logback.core.status.StatusManager;
021import ch.qos.logback.core.status.ViewStatusMessagesServletBase;
022
023public class ViewStatusMessagesServlet extends ViewStatusMessagesServletBase {
024
025    private static final long serialVersionUID = 443878494348593337L;
026
027    @Override
028    protected StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp) {
029
030        ServletContext sc = getServletContext();
031        return (StatusManager) sc.getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
032
033        // if (result != null) {
034        // System.out.println("from ServletContext");
035        // return result;
036        // } else {
037        // HttpSession httpSession = req.getSession(true);
038        //
039        // System.out.println("from httpSession");
040        // return (StatusManager) httpSession
041        // .getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
042        // }
043    }
044
045    @Override
046    protected String getPageTitle(HttpServletRequest req, HttpServletResponse resp) {
047        return "<h2>Status messages for logback-access</h2>\r\n";
048    }
049}