org.apache.logging.log4j.core.appender.RollingFileAppender.start()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(17.4k)|赞(0)|评价(0)|浏览(260)

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

RollingFileAppender.start介绍

暂无

代码示例

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

@Override
public void activateAppenderWithSizeRolling(String productName, String file, String encoding, String size,
                      int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%i")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(SizeBasedTriggeringPolicy.createPolicy(size))
    .withStrategy(DefaultRolloverStrategy
      .createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size,
                          String datePattern, int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}.%i")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"),
      SizeBasedTriggeringPolicy.createPolicy(size)))
    .withStrategy(DefaultRolloverStrategy
      .createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppender(String productName, String file, String encoding) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"))
    .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size,
                          String datePattern) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"),
      SizeBasedTriggeringPolicy.createPolicy(size)))
    .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size, String datePattern, int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}.%i")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"), SizeBasedTriggeringPolicy.createPolicy(size)))
      .withStrategy(DefaultRolloverStrategy.createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

@Override
public void activateAppender(String productName, String file, String encoding) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"))
      .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

@Override
public void activateAppenderWithSizeRolling(String productName, String file, String encoding, String size, int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%i")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(SizeBasedTriggeringPolicy.createPolicy(size))
      .withStrategy(DefaultRolloverStrategy.createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.taobao.middleware/logger.core

@Override
public void activateAppenderWithSizeRolling(String productName, String file, String encoding, String size, int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%i")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(SizeBasedTriggeringPolicy.createPolicy(size))
      .withStrategy(DefaultRolloverStrategy.createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size, String datePattern) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"), SizeBasedTriggeringPolicy.createPolicy(size)))
      .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppenderWithSizeRolling(String productName, String file, String encoding, String size,
                      int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%i")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(SizeBasedTriggeringPolicy.createPolicy(size))
    .withStrategy(DefaultRolloverStrategy
      .createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: igvteam/igv

public static void initializeLog() {
  // Create a log file that is ready to have text appended to it
  try {
    File logFile = getLogFile();
    LoggerContext context = LoggerContext.getContext(false);
    Configuration configuration = context.getConfiguration();
    LoggerConfig rootLogger = configuration.getRootLogger();
    rootLogger.removeAppender("IGV_ROLLING_APPENDER");
    PatternLayout layout = PatternLayout.newBuilder().withConfiguration(configuration)
        .withPattern("%p [%d{ISO8601}] [%F:%L]  %m%n").build();
    RollingFileAppender appender = RollingFileAppender.newBuilder().withName("IGV_ROLLING_APPENDER")
        .setConfiguration(configuration)
        .withFileName(logFile.getAbsolutePath()).withAppend(true)
        .withFilePattern(getIgvDirectory().getAbsolutePath() + File.pathSeparator + "igv-%i.log")
        .withLayout(layout)
        .withPolicy(SizeBasedTriggeringPolicy.createPolicy("1000K"))
        .build();
    appender.start();
    configuration.addAppender(appender);
    rootLogger.addAppender(appender, Level.ALL, null);
    context.updateLoggers();
  } catch (IOException e) {
    // Can't create log file, just log to console as set in log4j2.xml
    log.error("Error creating log file", e);
  }
}

代码示例来源:origin: com.taobao.middleware/logger.core

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size, String datePattern, int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}.%i")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"), SizeBasedTriggeringPolicy.createPolicy(size)))
      .withStrategy(DefaultRolloverStrategy.createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size,
                          String datePattern, int maxBackupIndex) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}.%i")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"),
      SizeBasedTriggeringPolicy.createPolicy(size)))
    .withStrategy(DefaultRolloverStrategy
      .createStrategy(String.valueOf(maxBackupIndex), "1", "max", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.taobao.middleware/logger.core

@Override
public void activateAppender(String productName, String file, String encoding) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"))
      .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppender(String productName, String file, String encoding) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"))
    .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

代码示例来源:origin: com.taobao.middleware/logger.core

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size, String datePattern) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
      .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
      .withFileName(LoggerHelper.getLogFileP(productName, file))
      .withAppend(true)
      .withBufferedIo(true)
      .setConfiguration(configuration)
      .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}")
      .withLayout(buildLayout(encoding))
      .withCreateOnDemand(false)
      .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"), SizeBasedTriggeringPolicy.createPolicy(size)))
      .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
      .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

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

@Override
public void activateAppenderWithTimeAndSizeRolling(String productName, String file, String encoding, String size,
                          String datePattern) {
  org.apache.logging.log4j.core.appender.RollingFileAppender appender = RollingFileAppender.newBuilder()
    .withName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender")
    .withFileName(LoggerHelper.getLogFileP(productName, file))
    .withAppend(true)
    .withBufferedIo(true)
    .setConfiguration(configuration)
    .withFilePattern(LoggerHelper.getLogFile(productName, file) + ".%d{" + datePattern + "}")
    .withLayout(buildLayout(encoding))
    .withCreateOnDemand(false)
    .withPolicy(CompositeTriggeringPolicy.createPolicy(TimeBasedTriggeringPolicy.createPolicy("1", "true"),
      SizeBasedTriggeringPolicy.createPolicy(size)))
    .withStrategy(DefaultRolloverStrategy.createStrategy(null, null, "nomax", null, null, false, configuration))
    .build();
  appender.start();
  removeAllAppenders(logger);
  logger.addAppender(appender);
  setProductName(productName);
}

相关文章