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.jetty;
015
016import ch.qos.logback.access.spi.IAccessEvent;
017import ch.qos.logback.access.PatternLayoutEncoder;
018import ch.qos.logback.access.testUtil.NotifyingListAppender;
019import ch.qos.logback.core.ConsoleAppender;
020
021public class JettyFixtureWithListAndConsoleAppenders extends JettyFixtureBase {
022
023    public JettyFixtureWithListAndConsoleAppenders(RequestLogImpl impl, int port) {
024        super(impl, port);
025        url = "http://localhost:" + port + "/";
026    }
027
028    public void start() throws Exception {
029        super.start();
030        Thread.yield();
031    }
032
033    public void stop() throws Exception {
034        super.stop();
035        Thread.sleep(500);
036    }
037
038    @Override
039    protected void configureRequestLogImpl() {
040        NotifyingListAppender appender = new NotifyingListAppender();
041        appender.setContext(requestLogImpl);
042        appender.setName("list");
043        appender.start();
044
045        ConsoleAppender<IAccessEvent> console = new ConsoleAppender<IAccessEvent>();
046        console.setContext(requestLogImpl);
047        console.setName("console");
048        PatternLayoutEncoder layout = new PatternLayoutEncoder();
049        layout.setContext(requestLogImpl);
050        layout.setPattern("%date %server %clientHost");
051        console.setEncoder(layout);
052        layout.start();
053        console.start();
054
055        requestLogImpl.addAppender(appender);
056        requestLogImpl.addAppender(console);
057    }
058}