View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, 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.classic.issue.DarioCampagna;
15  
16  import ch.qos.cal10n.IMessageConveyor;
17  import ch.qos.cal10n.MessageConveyor;
18  import ch.qos.logback.classic.LoggerContext;
19  import ch.qos.logback.classic.joran.JoranConfigurator;
20  import ch.qos.logback.core.joran.spi.JoranException;
21  import org.slf4j.LoggerFactory;
22  import org.slf4j.Marker;
23  import org.slf4j.MarkerFactory;
24  import org.slf4j.cal10n.LocLogger;
25  import org.slf4j.cal10n.LocLoggerFactory;
26  
27  import java.util.Locale;
28  
29  public class Main {
30      public static void main(String[] args) throws JoranException {
31  
32          LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
33          context.reset();
34          JoranConfigurator joranConfigurator = new JoranConfigurator();
35          joranConfigurator.setContext(context);
36          joranConfigurator.doConfigure("src/test/java/ch/qos/logback/classic/issue/DarioCampagna/logback-marker.xml");
37          IMessageConveyor mc = new MessageConveyor(Locale.getDefault());
38          LocLoggerFactory llFactory_default = new LocLoggerFactory(mc);
39          LocLogger locLogger = llFactory_default.getLocLogger("defaultLocLogger");
40          Marker alwaysMarker = MarkerFactory.getMarker("ALWAYS");
41          locLogger.info(alwaysMarker, "This will always appear.");
42          locLogger.info("Hello!");
43      }
44  }