本文整理了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
暂无
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!