本文整理了Java中ch.qos.logback.core.rolling.RollingFileAppender.setName
方法的一些代码示例,展示了RollingFileAppender.setName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RollingFileAppender.setName
方法的具体详情如下:
包路径:ch.qos.logback.core.rolling.RollingFileAppender
类名称:RollingFileAppender
方法名:setName
暂无
代码示例来源: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: SonarSource/sonarqube
@Override
public FileAppender<ILoggingEvent> createAppender(String appenderName) {
RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
appender.setContext(context);
appender.setName(appenderName);
String filePath = new File(logsDir, filenamePrefix + ".log").getAbsolutePath();
appender.setFile(filePath);
TimeBasedRollingPolicy rollingPolicy = new TimeBasedRollingPolicy();
rollingPolicy.setContext(context);
rollingPolicy.setFileNamePattern(StringUtils.replace(filePath, filenamePrefix + ".log", filenamePrefix + ".%d{" + datePattern + "}.log"));
rollingPolicy.setMaxHistory(maxFiles);
rollingPolicy.setParent(appender);
rollingPolicy.start();
appender.setRollingPolicy(rollingPolicy);
return appender;
}
}
代码示例来源: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
fileAppender.setName("application");
fileAppender.setFile(file);
fileAppender.setAppend(true);
代码示例来源:origin: apache/incubator-dubbo
fileAppender.setName("application");
fileAppender.setFile(file);
fileAppender.setAppend(true);
代码示例来源:origin: SonarSource/sonarqube
@Override
public FileAppender<ILoggingEvent> createAppender(String appenderName) {
RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
appender.setContext(context);
appender.setName(appenderName);
String filePath = new File(logsDir, filenamePrefix + ".log").getAbsolutePath();
appender.setFile(filePath);
SizeBasedTriggeringPolicy<ILoggingEvent> trigger = new SizeBasedTriggeringPolicy<>();
trigger.setMaxFileSize(FileSize.valueOf(size));
trigger.setContext(context);
trigger.start();
appender.setTriggeringPolicy(trigger);
FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
rollingPolicy.setContext(context);
rollingPolicy.setFileNamePattern(StringUtils.replace(filePath, filenamePrefix + ".log", filenamePrefix + ".%i.log"));
rollingPolicy.setMinIndex(1);
rollingPolicy.setMaxIndex(maxFiles);
rollingPolicy.setParent(appender);
rollingPolicy.start();
appender.setRollingPolicy(rollingPolicy);
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);
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
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.setContext(LogbackLoggerContextUtil.getLoggerContext());
appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));
代码示例来源:origin: alibaba/nacos
appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));
代码示例来源:origin: alibaba/nacos
appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));
代码示例来源:origin: alibaba/nacos
appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
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: dswarm/dswarm
private RollingFileAppender<ILoggingEvent> rollingAppender(final CharSequence baseName, final Context context) {
final RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<>();
fileAppender.setContext(context);
fileAppender.setName(name);
fileAppender.setFile(filePath(baseName, "log"));
return fileAppender;
}
代码示例来源: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: 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
RollingFileAppender<String> buildRollingFileAppender(String name, String filenameSuffix, String patternSuffix) {
RollingFileAppender<String> rollingFileAppender = new RollingFileAppender<String>();
rollingFileAppender.setName(name);
rollingFileAppender.setContext(context);
rollingFileAppender.setFile(randomOutputDir+filenameSuffix);
rollingFileAppender.setEncoder(new NopEncoder<String>());
TimeBasedRollingPolicy<String> tbrp = new TimeBasedRollingPolicy<String>();
tbrp.setContext(context);
tbrp.setFileNamePattern(randomOutputDir+patternSuffix);
tbrp.setParent(rollingFileAppender);
//tbrp.timeBasedFileNamingAndTriggeringPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy<Object>();
//tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(givenTime);
rollingFileAppender.setRollingPolicy(tbrp);
tbrp.start();
return rollingFileAppender;
}
内容来源于网络,如有侵权,请联系作者删除!