当前位置: 首页>>代码示例>>Java>>正文


Java LayoutWrappingEncoder.setContext方法代码示例

本文整理汇总了Java中ch.qos.logback.core.encoder.LayoutWrappingEncoder.setContext方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutWrappingEncoder.setContext方法的具体用法?Java LayoutWrappingEncoder.setContext怎么用?Java LayoutWrappingEncoder.setContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.core.encoder.LayoutWrappingEncoder的用法示例。


在下文中一共展示了LayoutWrappingEncoder.setContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
@Override
public void configure(final LoggerContext lc) {

    final ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
    ca.setContext(lc);
    ca.setName("console");
    final LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
    encoder.setContext(lc);
    final TTLLLayout layout = new TTLLLayout();
    layout.setContext(lc);
    layout.start();
    encoder.setLayout(layout);
    ca.setEncoder(encoder);
    ca.start();
    final Logger rootLogger = lc.getLogger("ROOT");
    rootLogger.setLevel(Level.WARN);
    rootLogger.addAppender(ca);
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:19,代码来源:LogConfigurator.java

示例2: configure

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
@Override
public void configure(LoggerContext lc) {
  addInfo("Setting up robot logging configuration.");

  ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
  ca.setContext(lc);
  ca.setName("console");
  LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
  encoder.setContext(lc);

  PatternLayout layout = new PatternLayout();
  layout.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");

  layout.setContext(lc);
  layout.start();
  encoder.setLayout(layout);

  ca.setEncoder(encoder);
  ca.start();

  Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
  rootLogger.addAppender(ca);
  rootLogger.setLevel(Level.DEBUG);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:25,代码来源:LoggingConfigurator.java

示例3: setLayout

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
/**
 * レイアウトの設定<br>
 * 通常は {@link #setEncoder(Encoder)}を利用する
 *
 * @param layout {@code <layout>}
 */
public void setLayout(Layout<E> layout) {
	LayoutWrappingEncoder<E> lwe = new LayoutWrappingEncoder<>();
	lwe.setLayout(layout);
	lwe.setContext(this.context);
	this.encoder = lwe;
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:13,代码来源:AbstractEncodedAppender.java

示例4: configure

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
@Override
public void configure(LoggerContext lc) {
  addInfo("Setting up robot logging configuration.");

  FileAppender<ILoggingEvent> fa = new FileAppender<>();
  fa.setFile("tct.log");
  fa.setAppend(true);
  ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
  ca.setContext(lc);
  ca.setName("console");
  fa.setContext(lc);
  fa.setName("logfile");
  LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
  encoder.setContext(lc);

  PatternLayout layout = new PatternLayout();
  layout.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");

  layout.setContext(lc);
  layout.start();
  encoder.setLayout(layout);

  ca.setEncoder(encoder);
  //    ca.start();
  fa.setEncoder(encoder);
  fa.start();

  Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
  //    rootLogger.addAppender(ca);
  rootLogger.addAppender(fa);
  rootLogger.setLevel(Level.WARN);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:33,代码来源:LoggingConfigurator.java

示例5: setupConsoleLogging

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
/**
 * Sets up SLF4J logging for {@link System#out} and {@link System#err} at INFO level.
 * The logger also logs to {@link ClientSettings#LOGGING_FILE}, with the same format as for the console.
 */
private static void setupConsoleLogging() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);

    ConsoleAppender<ILoggingEvent> consoleAppender =
            (ConsoleAppender<ILoggingEvent>) root.getAppender("console");

    LayoutWrappingEncoder<ILoggingEvent> consoleWrappingEncoder =
            (LayoutWrappingEncoder<ILoggingEvent>) consoleAppender.getEncoder();

    LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
    encoder.setLayout(consoleWrappingEncoder.getLayout());
    encoder.setCharset(Charset.forName("UTF-16"));
    encoder.setContext(root.getLoggerContext());
    encoder.start();

    FileAppender<ILoggingEvent> logFileAppender = new FileAppender<>();
    logFileAppender.setFile(ClientSettings.LOGGING_FILE);
    logFileAppender.setContext(root.getLoggerContext());
    logFileAppender.setEncoder(encoder);
    logFileAppender.setAppend(false);
    logFileAppender.start();

    root.addAppender(logFileAppender);

    SysOutOverSLF4J.sendSystemOutAndErrToSLF4J();
}
 
开发者ID:Wingman,项目名称:wingman,代码行数:32,代码来源:Main.java

示例6: setLayout

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
public void setLayout(Layout<E> layout) {
  addWarn("This appender no longer admits a layout as a sub-component, set an encoder instead.");
  addWarn("To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.");
  addWarn("See also "+CODES_URL+"#layoutInsteadOfEncoder for details");
  LayoutWrappingEncoder<E> lwe = new LayoutWrappingEncoder<E>();
  lwe.setLayout(layout);
  lwe.setContext(context);
  this.encoder = lwe;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:OutputStreamAppender.java

示例7: headerFooterCheck

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
public void headerFooterCheck(String fileHeader, String presentationHeader, String presentationFooter, String fileFooter) {
  OutputStreamAppender<Object> wa = new OutputStreamAppender<Object>();
  wa.setContext(context);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
  SamplePatternLayout<Object> spl = new SamplePatternLayout<Object>();
  spl.setContext(context);

  spl.setFileHeader(fileHeader);
  spl.setPresentationHeader(presentationHeader);
  spl.setPresentationFooter(presentationFooter);
  spl.setFileFooter(fileFooter);

  spl.start();
  LayoutWrappingEncoder<Object> encoder = new LayoutWrappingEncoder<Object>();
  encoder.setLayout(spl);
  encoder.setContext(context);
  
  wa.setEncoder(encoder);
  wa.setOutputStream(baos);
  wa.start();
  
  wa.stop();
  String result = baos.toString();

  String expectedHeader = emtptyIfNull(fileHeader) + emtptyIfNull(presentationHeader);

  System.out.println(result);
  assertTrue(result, result.startsWith(expectedHeader));

  String expectedFooter = emtptyIfNull(presentationFooter) + emtptyIfNull(fileFooter);
  assertTrue(result, result.endsWith(expectedFooter));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:34,代码来源:OutputStreamAppenderTest.java

示例8: PhialLogger

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入方法依赖的package包/类
/**
 * Creates Logger that will write logs in html file using slf4j and logback.
 * The logs will be included in Phial Attachment
 *
 * @param context application context
 */
public PhialLogger(Context context) {
    logDir = createLogDir(context);
    clearOldLogs(logDir);

    final String logDirectory = logDir.getAbsolutePath();
    // reset the default context (which may already have been initialized)
    // since we want to reconfigure it
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.reset();

    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
    rollingFileAppender.setContext(loggerContext);
    rollingFileAppender.setAppend(true);
    rollingFileAppender.setFile(logDirectory + "/" + LOG_PREFIX + "-latest.html");

    SizeAndTimeBasedFNATP<ILoggingEvent> fileNamingPolicy = new SizeAndTimeBasedFNATP<>();
    fileNamingPolicy.setContext(loggerContext);
    fileNamingPolicy.setMaxFileSize(MAX_FILE_SIZE);

    TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<>();
    rollingPolicy.setContext(loggerContext);
    rollingPolicy.setFileNamePattern(logDirectory + "/" + LOG_PREFIX + HISTORY_FILE_NAME_PATTERN);
    rollingPolicy.setMaxHistory(5);
    rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(fileNamingPolicy);
    rollingPolicy.setParent(rollingFileAppender);  // parent and context required!
    rollingPolicy.start();

    HTMLLayout htmlLayout = new HTMLLayout();
    htmlLayout.setContext(loggerContext);
    htmlLayout.setPattern(PATTERN);
    htmlLayout.start();

    LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
    encoder.setContext(loggerContext);
    encoder.setLayout(htmlLayout);
    encoder.start();

    rollingFileAppender.setRollingPolicy(rollingPolicy);
    rollingFileAppender.setEncoder(encoder);
    rollingFileAppender.start();

    // add the newly created appenders to the root logger;
    // qualify Logger to disambiguate from org.slf4j.Logger
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.DEBUG);
    root.addAppender(rollingFileAppender);
    // print any status messages (warnings, etc) encountered in logback config
    StatusPrinter.print(loggerContext);
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:56,代码来源:PhialLogger.java


注:本文中的ch.qos.logback.core.encoder.LayoutWrappingEncoder.setContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。