Package ch.qos.logback.classic

Examples of ch.qos.logback.classic.PatternLayout


        SyslogStartConverter.class.getName());
    prefixLayout.setPattern(prefixPattern);
    prefixLayout.setContext(getContext());
    prefixLayout.start();

    PatternLayout fullLayout = new PatternLayout();
    fullLayout.getInstanceConverterMap().put("syslogStart",
        SyslogStartConverter.class.getName());

    if (suffixPattern == null) {
      suffixPattern = DEFAULT_SUFFIX_PATTERN;
    }

    fullLayout.setPattern(prefixPattern + suffixPattern);
    fullLayout.setContext(getContext());
    fullLayout.start();
    return fullLayout;
  }
View Full Code Here


  @Override
  protected Layout<ILoggingEvent> makeSubjectLayout(String subjectStr) {
    if(subjectStr == null) {
      subjectStr = DEFAULT_SUBJECT_PATTERN;
    }
    PatternLayout pl = new PatternLayout();
    pl.setContext(getContext());
    pl.setPattern(subjectStr);
    // we don't want a ThrowableInformationConverter appended
    // to the end of the converter chain
    // This fixes issue LBCLASSIC-67
    pl.setPostCompileProcessor(null);
    pl.start();
    return pl;
  }
View Full Code Here

    // You can put values in the MDC at any time. We first put the
    // first name
    MDC.put("first", "Dorothy");

    // Configure logback
    PatternLayout layout = new PatternLayout();
    layout.setPattern("%X{first} %X{last} - %m%n");
    layout.start();
    ConsoleAppender appender = new ConsoleAppender();
    appender.setLayout(layout);
    appender.start();
    Logger root = (Logger)LoggerFactory.getLogger("root");
    root.addAppender(appender);
View Full Code Here

    // A FileAppender is created according to the buffering and
    // immediate flush setting of this IO instance.
    FileAppender fa = new FileAppender();

    if (longMessage) {
      PatternLayout pa = new PatternLayout();
      pa.setPattern("%r %5p %c [%t] - %m%n");
      fa.setLayout(pa);
    } else {
      fa.setLayout(new EchoLayout());
    }
View Full Code Here

public class PatternSample {

  static public void main(String[] args) throws Exception {
    Logger rootLogger = (Logger) LoggerFactory.getLogger("root");
   
    PatternLayout layout = new PatternLayout();
    layout.setPattern("%-5level [%thread]: %message%n");
    layout.start();
   
    ConsoleAppender appender = new ConsoleAppender();
    appender.setContext(rootLogger.getLoggerContext());
    appender.setLayout(layout);
    appender.start();
View Full Code Here

        ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
        rootLogger.addAppender(appender);
        appender.setContext(context);
        appender.setTarget("System.err");

        PatternLayout layout = new PatternLayout();
        appender.setLayout(layout);
        layout.setPattern("%msg%n%ex");
        layout.setContext(context);

        layout.start();
        appender.start();
    }
View Full Code Here

    ch.qos.logback.classic.Logger rootLogger =
      (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    LoggerContext loggerContext = rootLogger.getLoggerContext();

    this.patternLayout = new PatternLayout();
    this.patternLayout.setContext(loggerContext);
    this.patternLayout.setPattern(logPattern);
  }
View Full Code Here

    ch.qos.logback.classic.Logger rootLogger =
      (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    LoggerContext loggerContext = rootLogger.getLoggerContext();

    this.patternLayout = new PatternLayout();
    this.patternLayout.setContext(loggerContext);
    this.patternLayout.setPattern(logPattern);
  }
View Full Code Here

      tp = tp.getCause();
    }
  }

  public Layout<ILoggingEvent> buildLayout() {
    PatternLayout layout = new PatternLayout();
    layout.getInstanceConverterMap().put("syslogStart",
            SyslogStartConverter.class.getName());
    if (suffixPattern == null) {
      suffixPattern = DEFAULT_SUFFIX_PATTERN;
    }
    layout.setPattern(getPrefixPattern() + suffixPattern);
    layout.setContext(getContext());
    layout.start();
    return layout;
   }
View Full Code Here

    // You can put values in the MDC at any time. We first put the
    // first name
    MDC.put("first", "Dorothy");

    // Configure logback
    PatternLayout layout = new PatternLayout();
    layout.setPattern("%X{first} %X{last} - %m%n");
    layout.start();
    ConsoleAppender<LoggingEvent> appender = new ConsoleAppender<LoggingEvent>();
    appender.setLayout(layout);
    appender.start();
    // cast root logger to c.q.logback.classic.Logger so that we can attach an
    // appender to it
View Full Code Here

TOP

Related Classes of ch.qos.logback.classic.PatternLayout

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.