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


Java LayoutWrappingEncoder类代码示例

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


LayoutWrappingEncoder类属于ch.qos.logback.core.encoder包,在下文中一共展示了LayoutWrappingEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: encoderCharset

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
@Test
public void encoderCharset() throws JoranException, IOException,
        InterruptedException {

  String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
          + "encoderCharset.xml";
  configure(configFileAsStr);

  ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) root.getAppender("CONSOLE");
  assertNotNull(consoleAppender);
  LayoutWrappingEncoder<ILoggingEvent> encoder = (LayoutWrappingEncoder<ILoggingEvent>) consoleAppender.getEncoder();

  assertEquals("UTF-8", encoder.getCharset().displayName());

  StatusChecker checker = new StatusChecker(loggerContext);
  checker.assertIsErrorFree();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:JoranConfiguratorTest.java

示例4: setupOwnLogger

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
private static void setupOwnLogger() {
	LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

	logger = (Logger) LoggerFactory.getLogger(Values.BOT_NAME);
	ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();
	consoleAppender.setContext(lc);
	consoleAppender.setName("console");
	LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();

	PatternLayout layout = new PatternLayout();
	layout.setPattern("[%d{HH:mm:ss}] [%level] [%logger] %msg%n");
	layout.setContext(lc);
	layout.start();
	encoder.setLayout(layout);

	consoleAppender.setEncoder(encoder);
	consoleAppender.start();

	// disable default appender
	logger.setAdditive(false);

	// enable custom console appender
	logger.addAppender(consoleAppender);

	// set logging level
	if(a.isDebug()) {
		logger.setLevel(Level.DEBUG);
	} else {
		logger.setLevel(Level.INFO);
	}
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:32,代码来源:Log.java

示例5: 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

示例6: getCharset

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
/**
 * Charset取得 (取れる範囲で)
 *
 * @return Charset
 */
protected Charset getCharset() {

	Charset charset = null;
	if (this.encoder instanceof LayoutWrappingEncoder) {
		charset = ((LayoutWrappingEncoder<?>) this.encoder).getCharset();
	}
	return charset != null ? charset : Charset.defaultCharset();

}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:15,代码来源:AbstractEncodedAppender.java

示例7: 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

示例8: 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

示例9: setImmediateFlush

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
public boolean setImmediateFlush(boolean enable) {
    FileAppender<ILoggingEvent> fileLogger = getFileLogger();
    Encoder<ILoggingEvent> encoder = fileLogger.getEncoder();
    if (encoder instanceof LayoutWrappingEncoder) {
        ((LayoutWrappingEncoder) encoder).setImmediateFlush(enable);
        return true;
    }
    return false;
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:10,代码来源:Logging.java

示例10: isImmediateFlush

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
public boolean isImmediateFlush() {
    FileAppender<ILoggingEvent> fileLogger = getFileLogger();
    Encoder<ILoggingEvent> encoder = fileLogger.getEncoder();
    if (encoder instanceof LayoutWrappingEncoder) {
        return ((LayoutWrappingEncoder) encoder).isImmediateFlush();
    }
    return false;
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:9,代码来源:Logging.java

示例11: 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

示例12: 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

示例13: layoutInsteadOfEncoer

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
@Test
public void layoutInsteadOfEncoer() throws JoranException {
  jc.doConfigure(ClassicTestConstants.JORAN_INPUT_PREFIX
      + "compatibility/layoutInsteadOfEncoder.xml");
  StatusPrinter.print(loggerContext);
  StatusChecker checker = new StatusChecker(loggerContext);
  checker.assertContainsMatch(Status.WARN, "This appender no longer admits a layout as a sub-component");
  checker.assertContainsMatch(Status.WARN, "See also "+CODES_URL+"#layoutInsteadOfEncoder for details");
  
  ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
  FileAppender<ILoggingEvent> fileAppender = (FileAppender<ILoggingEvent>) root.getAppender("LIOE");
  assertTrue(fileAppender.isStarted());
  assertTrue(fileAppender.getEncoder() instanceof LayoutWrappingEncoder);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:LayoutInsteadOfEncoderTest.java

示例14: getEncoding

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
@Override
public String getEncoding() {
  if (getTarget() instanceof OutputStreamAppender) {
    OutputStreamAppender<?> appender = (OutputStreamAppender<?>) getTarget();
    Encoder<?> encoder = appender.getEncoder();
    if (encoder instanceof LayoutWrappingEncoder) {
      LayoutWrappingEncoder<?> base = (LayoutWrappingEncoder<?>) encoder;
      if (base.getCharset() != null) {
        return base.getCharset().name();
      }
      return null;
    }
  }
  return null;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:16,代码来源:LogbackAppenderAccessor.java

示例15: createAppender

import ch.qos.logback.core.encoder.LayoutWrappingEncoder; //导入依赖的package包/类
@Override
public Appender<ILoggingEvent> createAppender(LoggerContext context, String defaultLogFormat) {

    LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
    encoder.setLayout(createLayout(context, defaultLogFormat));

    FileAppender<ILoggingEvent> appender = (rollingPolicy == null)
            ? createSingleFileAppender(encoder, context)
            : createRollingFileAppender(encoder, context, rollingPolicy);

    return asAsync(appender);
}
 
开发者ID:bootique,项目名称:bootique-logback,代码行数:13,代码来源:FileAppenderFactory.java


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