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

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

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

RollingFileAppender.setAppend介绍

暂无

代码示例

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

fileAppender.setName("application");
fileAppender.setFile(file);
fileAppender.setAppend(true);

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

fileAppender.setName("application");
fileAppender.setFile(file);
fileAppender.setAppend(true);

代码示例来源: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: 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);
  PatternLayout layout = new PatternLayout();
  layout.setPattern(LoggerHelper.getPattern(productName));
  layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
  layout.start();
  appender.setLayout(layout);
  // 启动
  appender.start();
  return appender;
}

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

appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));

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

appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));

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

appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));

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

appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));

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

static {
  try {
    String logFileName = "neo4j.log";
    RollingFileAppender fa = new RollingFileAppender();
    fa.setName("NEO4JLOGGER");
    fa.setFile(logFileName);
    fa.setLayout(new PatternLayout(
        "[%d{dd.MM.yyyy HH:mm:ss.SSS}]  %5p %c{1}:%L - %m%n"));
    fa.setAppend(true);
    fa.activateOptions();
    Logger.getLogger("CLASSES NEEDED TO BE LOGGED").setLevel(Level.ALL);
    Logger.getLogger("CLASSES NEEDED TO BE LOGGED").addAppender(fa);

  } catch (Exception ex) {
    logger.error("Intialize Logger :: Failed...  \n   ", ex);
  }
}

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

public Logger generateLogger(String parent, String name, String logDirectory, String filePattern, String fileThreshold) {
  // TODO Auto-generated method stub

  //Create Logger 
      String loggerName = parent + "." + name;
      Logger log = Logger.getLogger(loggerName);

      //Create Logging File Appender
      RollingFileAppender fileApp = new RollingFileAppender();
      fileApp.setName("Broker." + loggerName + "_FileAppender");
      fileApp.setFile(logDirectory +"/"+ name+".log");
      fileApp.setLayout(new PatternLayout(filePattern));
      fileApp.setThreshold(Level.toLevel(fileThreshold));
      fileApp.setAppend(true);
      fileApp.activateOptions();

      log.addAppender(fileApp);

      return log;     
}

代码示例来源: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: stackoverflow.com

private Logger logger = null;
private RollingFileAppender appender = null;

private void init(String NameForAppender, String Name4LogFile) {
  logger = Logger.getLogger(NameForAppender); //NOT DEFAULT BY "logger = Logger.getLogger(TestJob.class);"

  appender = new RollingFileAppender();
  appender.setName(NameForAppender); //<-- I think this helps in pair of the Logger.getLogger(NameForAppender) above
  appender.setLayout(new PatternLayout("%d{yyyy-MM-dd/HH:mm:ss.SSS/zzz} %-5p %c{1}:%L - %m%n"));
  appender.setFile(Name4LogFile);
  appender.setAppend(true);
  appender.setImmediateFlush(true);
  appender.setMaxFileSize("100MB");
  appender.setMaxBackupIndex(10);
  appender.activateOptions();

  logger.setAdditivity(false);    //<--do not use default root logger
  logger.addAppender(appender);
}

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

static
{
  if (null == LOGGER.getAppender("TEST_LOG_APPENDER"))
  {
    RollingFileAppender fa = new RollingFileAppender();
    fa.setName("TEST_LOG_APPENDER");
    fa.setFile("/test-output/" + "App_1.log");
    fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
    fa.setThreshold(Level.DEBUG);
    fa.setAppend(true);
    fa.setMaxFileSize("10MB");
    fa.activateOptions();
    LOGGER.addAppender(fa);
  }
}

代码示例来源:origin: epam/DLab

/** Create and return synchronous the rolling file appender.
 * @param context the context of logger. 
 */
private RollingFileAppender<ILoggingEvent> getRollingFileAppender(LoggerContext context) throws InitializationException {
  if (archivedLogFilenamePattern == null || archivedLogFilenamePattern.trim().isEmpty()) {
    throw new InitializationException("Configuration property logging.appenders.archivedLogFilenamePattern cannot be null.");
  }
  RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<ILoggingEvent>();
  appender.setFile(currentLogFilename);
  appender.setAppend(true);
  TimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggerPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
  triggerPolicy.setContext(context);
  
  TimeBasedRollingPolicy<ILoggingEvent> rollPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
  rollPolicy.setContext(context);
  rollPolicy.setParent(appender);
  rollPolicy.setFileNamePattern(archivedLogFilenamePattern);
  rollPolicy.setMaxHistory(archivedFileCount);
  rollPolicy.setTimeBasedFileNamingAndTriggeringPolicy(triggerPolicy);
  rollPolicy.start();
  appender.setRollingPolicy(rollPolicy);
  
  return appender;
}

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

@Test
public void testPrudentModeLogicalImplicationsOnCompression() {
 rfa.setContext(context);
 rfa.setAppend(false);
 rfa.setPrudent(true);
 tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-%d.log.zip");
 tbrp.start();
 rfa.setRollingPolicy(tbrp);
 rfa.start();
 StatusChecker checker = new StatusChecker(context);
 assertFalse(rfa.isStarted());
 assertEquals(Status.ERROR, checker.getHighestLevel(0));
}

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

@Test
public void testPrudentModeLogicalImplications() {
 rfa.setContext(context);
 // prudent mode will force "file" property to be null
 rfa.setFile("some non null value");
 rfa.setAppend(false);
 rfa.setPrudent(true);
 tbrp
     .setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-%d.log");
 tbrp.start();
 rfa.setRollingPolicy(tbrp);
 rfa.start();
 assertTrue(rfa.isAppend());
 assertNull(rfa.rawFileProperty());
 assertTrue(rfa.isStarted());
}

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

@Test
public void collidingTimeformat() {
 rfa.setContext(context);
 rfa.setAppend(false);
 rfa.setPrudent(true);
 tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-%d{dd}.log.zip");
 tbrp.start();
 rfa.setRollingPolicy(tbrp);
 rfa.start();
 StatusChecker checker = new StatusChecker(context);
 assertFalse(rfa.isStarted());
 assertEquals(Status.ERROR, checker.getHighestLevel(0));
 StatusPrinter.print(context);
 checker.assertContainsMatch("The date format in FileNamePattern will result");
}

代码示例来源:origin: com.alibaba.nacos/nacos-client

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: tony19/logback-android

@SuppressWarnings("unchecked")
static LoggerContext buildLoggerContext(String stamp, String filename,
  boolean safetyMode) {
 LoggerContext loggerContext = new LoggerContext();
 RollingFileAppender<ILoggingEvent> rfa = new RollingFileAppender<ILoggingEvent>();
 PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
 patternLayout.setPattern(stamp + " %5p - %-50m%n");
 patternLayout.setContext(loggerContext);
 patternLayout.start();
 rfa.setEncoder(patternLayout);
 
 rfa.setAppend(true);
 rfa.setPrudent(safetyMode);
 rfa.setContext(loggerContext);
 TimeBasedRollingPolicy<ILoggingEvent> tbrp = new TimeBasedRollingPolicy();
 
 tbrp.setContext(loggerContext);
 tbrp.setFileNamePattern(filename+"-%d{"+DATE_PATTERN+"}.log");
 tbrp.setParent(rfa);
 tbrp.start();

 rfa.setRollingPolicy(tbrp);
 
 rfa.start();
 ch.qos.logback.classic.Logger root = loggerContext
   .getLogger(Logger.ROOT_LOGGER_NAME);
 root.addAppender(rfa);
 return loggerContext;
}

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

public RollingFileHandler(String filename, int maxHistory, long maxSizeInBytes)
{
  setFormatter(new StaticFormatter());
  ContextBase context = new ContextBase();
  recoverTempFiles(filename);
  RollingFileAppender<String> fileAppender = new RollingFileAppender<>();
  TimeBasedRollingPolicy<String> rollingPolicy = new TimeBasedRollingPolicy<>();
  SizeAndTimeBasedFNATP<String> triggeringPolicy = new SizeAndTimeBasedFNATP<>();
  rollingPolicy.setContext(context);
  rollingPolicy.setFileNamePattern(filename + "-%d{yyyy-MM-dd}.%i.log.gz");
  rollingPolicy.setMaxHistory(maxHistory);
  rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(triggeringPolicy);
  rollingPolicy.setParent(fileAppender);
  triggeringPolicy.setContext(context);
  triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
  triggeringPolicy.setMaxFileSize(new FileSize(maxSizeInBytes));
  fileAppender.setContext(context);
  fileAppender.setFile(filename);
  fileAppender.setAppend(true);
  fileAppender.setBufferSize(BUFFER_SIZE_IN_BYTES);
  fileAppender.setEncoder(new StringEncoder());
  fileAppender.setRollingPolicy(rollingPolicy);
  asyncAppender = new AsyncAppenderBase<>();
  asyncAppender.setContext(context);
  asyncAppender.addAppender(fileAppender);
  rollingPolicy.start();
  triggeringPolicy.start();
  fileAppender.start();
  asyncAppender.start();
}

相关文章