ch.qos.logback.core.rolling.RollingFileAppender.setEncoder()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中ch.qos.logback.core.rolling.RollingFileAppender.setEncoder方法的一些代码示例,展示了RollingFileAppender.setEncoder的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RollingFileAppender.setEncoder方法的具体详情如下:
包路径:ch.qos.logback.core.rolling.RollingFileAppender
类名称:RollingFileAppender
方法名:setEncoder

RollingFileAppender.setEncoder介绍

暂无

代码示例

代码示例来源:origin: gocd/gocd

private RollingFileAppender<ILoggingEvent> rollingAppender(String file) {
  RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
  rollingFileAppender.setEncoder(LogHelper.encoder("%date{ISO8601} - %msg%n"));
  rollingFileAppender.setContext(LogHelper.LOGGER_CONTEXT);
  rollingFileAppender.setFile(getEffectiveLogDirectory(file));
  rollingFileAppender.setName(UUID.randomUUID().toString());
  LogHelper.rollingPolicyForAppender(
      rollingFileAppender,
      "5 MB",
      "20 MB",
      4
  );
  rollingFileAppender.start();
  return rollingFileAppender;
}

代码示例来源:origin: gocd/gocd

private FileAppender<ILoggingEvent> getAppender(String pluginId) {
  File pluginLogFileLocation = pluginLogFile(pluginId);
  RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
  rollingFileAppender.setEncoder(LogHelper.encoder());
  rollingFileAppender.setContext(LogHelper.LOGGER_CONTEXT);
  rollingFileAppender.setFile(pluginLogFileLocation.getPath());
  rollingFileAppender.setName(rollingFileAppenderName(pluginId));
  LogHelper.rollingPolicyForAppender(
      rollingFileAppender,
      "5 MB",
      "20 MB",
      7
  );
  rollingFileAppender.start();
  return rollingFileAppender;
}

代码示例来源:origin: apache/incubator-dubbo

encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
encoder.start();
fileAppender.setEncoder(encoder);

代码示例来源:origin: apache/incubator-dubbo

encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
encoder.start();
fileAppender.setEncoder(encoder);

代码示例来源:origin: org.springframework.boot/spring-boot

private Appender<ILoggingEvent> fileAppender(LogbackConfigurator config,
    String logFile) {
  RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
  PatternLayoutEncoder encoder = new PatternLayoutEncoder();
  String logPattern = this.patterns.getProperty("logging.pattern.file",
      FILE_LOG_PATTERN);
  encoder.setPattern(OptionHelper.substVars(logPattern, config.getContext()));
  appender.setEncoder(encoder);
  config.start(encoder);
  appender.setFile(logFile);
  setRollingPolicy(appender, config, logFile);
  config.appender("FILE", appender);
  return appender;
}

代码示例来源:origin: kaaproject/kaa

encoder.start();
rfAppender.setEncoder(encoder);
rfAppender.setRollingPolicy(rollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);

代码示例来源:origin: alibaba/nacos

protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
                                     String encoding) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
  appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
  appender.setAppend(true);
  appender.setFile(LoggerHelper.getLogFile(productName, file));
  TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
  rolling.setParent(appender);
  rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
  rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
  rolling.start();
  appender.setRollingPolicy(rolling);
  PatternLayoutEncoder layout = new PatternLayoutEncoder();
  layout.setPattern(LoggerHelper.getPattern(productName));
  layout.setCharset(Charset.forName(encoding));
  appender.setEncoder(layout);
  layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
  layout.start();
  // 启动
  appender.start();
  return appender;
}

代码示例来源:origin: jmxtrans/jmxtrans

protected Appender buildAppender(String loggerName, String fileStr) {
  final RollingFileAppender appender = new RollingFileAppender();
  appender.setName(loggerName + "RollingFile");
  appender.setContext(loggerContext);
  appender.setImmediateFlush(true);
  appender.setBufferSize(new FileSize(LOG_IO_BUFFER_SIZE_BYTES));
  appender.setFile(fileStr);
  appender.setEncoder(buildEncoder());
  TriggeringPolicy triggeringPolicy = buildTriggeringPolicy();
  if (triggeringPolicy != null) {
    appender.setTriggeringPolicy(triggeringPolicy);
  }
  appender.setRollingPolicy(buildRollingPolicy(appender, fileStr));
  appender.start();
  return appender;
}

代码示例来源:origin: alibaba/nacos

layout.setPattern(LoggerHelper.getPattern(productName));
layout.setCharset(Charset.forName(encoding));
appender.setEncoder(layout);
layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();

代码示例来源:origin: stackoverflow.com

encoder.start();
rfAppender.setEncoder(encoder);
rfAppender.setRollingPolicy(rollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);

代码示例来源:origin: alibaba/nacos

layout.setPattern(LoggerHelper.getPattern(productName));
layout.setCharset(Charset.forName(encoding));
appender.setEncoder(layout);
layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();

代码示例来源:origin: tony19/logback-android

void initRFA(RollingFileAppender<Object> rfa) {
  rfa.setContext(context);
  rfa.setEncoder(encoder);
}

代码示例来源:origin: tony19/logback-android

private void initRFA(String filename) {
 rfa.setEncoder(encoder);
 if (filename != null) {
  rfa.setFile(filename);
 }
}

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

@Bean
  public RollingFileAppender<ILoggingEvent> fileAppender(SessionSettingsProvider sessionSettingsProvider, LoggerContext loggerContext, PatternLayoutEncoder encoder, FixedWindowRollingPolicy fixedWindowRollingPolicy, SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy) {
    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
    rollingFileAppender.setContext(loggerContext);
    rollingFileAppender.setEncoder(encoder);
    rollingFileAppender.setFile(sessionSettingsProvider.getLogsDirectory().resolve("desktop-client.log").toString());
    rollingFileAppender.setRollingPolicy(fixedWindowRollingPolicy);
    rollingFileAppender.setTriggeringPolicy(sizeBasedTriggeringPolicy);

    fixedWindowRollingPolicy.setParent(rollingFileAppender);

    return rollingFileAppender;
  }
}

代码示例来源:origin: tony19/logback-android

private void initRollingFileAppender(RollingFileAppender<Object> rfa, String filename) {
 rfa.setContext(context);
 rfa.setEncoder(encoder);
 if (filename != null) {
  rfa.setFile(filename);
 }
}

代码示例来源:origin: tony19/logback-android

private void initRFA(RollingFileAppender<Object> rfa, String filename) {
 rfa.setContext(context);
 rfa.setEncoder(encoder);
 if (filename != null) {
  rfa.setFile(filename);
 }
}

代码示例来源:origin: org.jmxtrans/jmxtrans-output-log4j

private RollingFileAppender buildAppender(Encoder encoder, RollingPolicy rollingPolicy) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setEncoder(encoder);
  appender.setAppend(true);
  appender.setContext(loggerContext);
  appender.setRollingPolicy(rollingPolicy);
  rollingPolicy.setParent(appender);
  return appender;
}

代码示例来源:origin: tony19/logback-android

@Before
public void setUp() throws Exception {
 encoder = new EchoEncoder<Object>();
 File outputDir = new File(outputDirStr);
 outputDir.mkdirs();
 System.out.println("Output dir [" + outputDirStr + "]");
 scriptOS = openScript();
 rfa.setName("rolling");
 rfa.setEncoder(encoder);
 rfa.setContext(context);
 rfa.setFile(outputDirStr + "output.log");
}

代码示例来源:origin: tony19/logback-android

@Before
public void setUp() throws Exception {
 // noStartTest fails if the context is set in setUp
 // rfa.setContext(context);
 rfa.setEncoder(new DummyEncoder<Object>());
 rfa.setName("test");
 tbrp.setContext(context);
 tbrp.setParent(rfa);
}

代码示例来源:origin: tony19/logback-android

private void buildRollingFileAppender(ConfigParameters cp) {
 rfa.setContext(context);
 rfa.setEncoder(encoder);
 tbrp.setContext(context);
 tbrp.setFileNamePattern(cp.fileNamePattern);
 tbrp.setMaxHistory(cp.maxHistory);
 tbrp.setTotalSizeCap(new FileSize(cp.sizeCap));
 tbrp.setParent(rfa);
 tbrp.setCleanHistoryOnStart(false);
 tbrp.timeBasedFileNamingAndTriggeringPolicy = tbfnatp;
 tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(cp.simulatedTime);
 tbrp.start();
 rfa.setRollingPolicy(tbrp);
 rfa.start();
}

相关文章