Package ch.qos.logback.core

Examples of ch.qos.logback.core.ConsoleAppender


import ch.qos.logback.core.ConsoleAppender;

public class BasicConfigurator {

  public static void configure(LoggerContext lc) {
    ConsoleAppender ca = new ConsoleAppender();
    ca.setContext(lc);
    ca.setName("console");
    PatternLayout pl = new PatternLayout();
    pl.setPattern("%-4relative [%thread] %-5level %class - %msg%n");
    pl.start();

    ca.setLayout(pl);
    ca.start();
    Logger rootLogger = lc.getLogger(LoggerContext.ROOT_NAME);
    rootLogger.addAppender(ca);
  }
View Full Code Here


  }

  @Test
  public void conditionalConsoleApp_IF_THEN_True() throws JoranException, UnknownHostException {
    configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole.xml");
    ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON");
    assertNotNull(consoleAppender);
    assertTrue(checker.isErrorFree(0));
  }
View Full Code Here

  public void conditionalConsoleApp_IF_THEN_False() throws JoranException,
          IOException, InterruptedException {
    context.putProperty("aHost", null);
    configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole.xml");

    ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON");
    assertNull(consoleAppender);

    StatusChecker checker = new StatusChecker(context);
    assertTrue(checker.isErrorFree(0));
  }
View Full Code Here

  @Test
  public void conditionalConsoleApp_ELSE() throws JoranException,
          IOException, InterruptedException {
    configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole_ELSE.xml");
    ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON");
    assertNull(consoleAppender);

    ListAppender listAppender = (ListAppender) context.getAppender("LIST");
    assertNotNull(listAppender);
    assertTrue(checker.isErrorFree(0));
View Full Code Here

            + "conditional/conditionalConsoleApp.xml";
    configure(configFileAsStr);
    FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
    assertNotNull(fileAppender);

    ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
    assertNotNull(consoleAppender);
    StatusChecker checker = new StatusChecker(context);
    checker.assertIsErrorFree();
  }
View Full Code Here

            + "conditional/conditionalConsoleApp.xml";
    configure(configFileAsStr);
    FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
    assertNotNull(fileAppender);

    ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
    assertNull(consoleAppender);
    StatusChecker checker = new StatusChecker(context);
    checker.assertIsErrorFree();
  }
View Full Code Here

    configure(configFileAsStr);

  FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
    assertNotNull(fileAppender);

    ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
    assertNull(consoleAppender);

    ListAppender listAppender = (ListAppender) root.getAppender("LIST");
    assertNotNull(listAppender);
View Full Code Here

     String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
             + "conditional/conditionalIncludeExistingFile.xml";
     configure(configFileAsStr);

     ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
     assertNotNull(consoleAppender);
     StatusChecker checker = new StatusChecker(context);
    checker.assertIsErrorFree();
   }
View Full Code Here

     String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
             + "conditional/conditionalIncludeInexistentFile.xml";
     configure(configFileAsStr);

     ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
     assertNull(consoleAppender);
     StatusChecker checker = new StatusChecker(context);
     checker.assertIsErrorFree();
   }
View Full Code Here

    PatternLayoutEncoder patternLayoutEncoder = new PatternLayoutEncoder();
    patternLayoutEncoder.setPattern("%-4relative [%thread] %-5level %logger{35} - %msg %n");
    patternLayoutEncoder.setContext(loggerContext);
    patternLayoutEncoder.start();

    ConsoleAppender consoleAppender = new ConsoleAppender();
    consoleAppender.setContext(loggerContext);
    consoleAppender.setName("CON");
    consoleAppender.setEncoder(patternLayoutEncoder);
    consoleAppender.start();

    Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.DEBUG);
    root.addAppender(consoleAppender);
View Full Code Here

TOP

Related Classes of ch.qos.logback.core.ConsoleAppender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.