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.classic.issue.lbcore211;
015
016import ch.qos.logback.classic.Logger;
017import ch.qos.logback.classic.LoggerContext;
018import ch.qos.logback.classic.joran.JoranConfigurator;
019import ch.qos.logback.core.joran.spi.JoranException;
020import ch.qos.logback.core.util.StatusPrinter;
021import org.junit.Test;
022import org.slf4j.LoggerFactory;
023
024/**
025 * @author Ceki Gülcü
026 */
027public class Lbcore211 {
028
029    @Test
030    public void lbcore211() throws JoranException {
031
032        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
033
034        JoranConfigurator configurator = new JoranConfigurator();
035        configurator.setContext(lc);
036        lc.reset();
037        configurator.doConfigure("/home/ceki/lbcore211.xml");
038
039        Logger l = lc.getLogger("file.logger");
040        StatusPrinter.print(lc);
041        for (int i = 0; i < 10; i++) {
042            l.info("hello " + i);
043        }
044
045        lc.stop();
046    }
047}