本文整理汇总了Java中ch.qos.logback.core.FileAppender.setPrudent方法的典型用法代码示例。如果您正苦于以下问题:Java FileAppender.setPrudent方法的具体用法?Java FileAppender.setPrudent怎么用?Java FileAppender.setPrudent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.core.FileAppender
的用法示例。
在下文中一共展示了FileAppender.setPrudent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFileAppender
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
public FileAppender<ILoggingEvent> buildFileAppender(LoggerContext context, String file) {
FileAppender<ILoggingEvent> fileAppender = new FileAppender<>();
fileAppender.setFile(file);
fileAppender.setContext(context);
fileAppender.setPrudent(true);
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern(primaryConfiguration.getLoggingPattern().or(baseConfiguration.getLoggingPattern()).or(JavaUtils.LOGBACK_LOGGING_PATTERN));
encoder.start();
fileAppender.setEncoder(encoder);
fileAppender.start();
return fileAppender;
}
示例2: buildLoggerContext
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
static LoggerContext buildLoggerContext(String stamp, String filename,
boolean safetyMode) {
LoggerContext loggerContext = new LoggerContext();
FileAppender<ILoggingEvent> fa = new FileAppender<ILoggingEvent>();
PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
patternLayout.setPattern(stamp + " %5p - %m%n");
patternLayout.setContext(loggerContext);
patternLayout.start();
fa.setEncoder(patternLayout);
fa.setFile(filename);
fa.setAppend(true);
fa.setPrudent(safetyMode);
fa.setContext(loggerContext);
fa.start();
ch.qos.logback.classic.Logger root = loggerContext
.getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(fa);
return loggerContext;
}
示例3: buildLoggerContext
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
static LoggerContext buildLoggerContext(String filename, boolean safetyMode) {
LoggerContext loggerContext = new LoggerContext();
FileAppender<ILoggingEvent> fa = new FileAppender<ILoggingEvent>();
PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
patternLayout.setPattern("%5p %c - %m%n");
patternLayout.setContext(loggerContext);
patternLayout.start();
fa.setEncoder(patternLayout);
fa.setFile(filename);
fa.setAppend(false);
fa.setPrudent(safetyMode);
fa.setContext(loggerContext);
fa.start();
ch.qos.logback.classic.Logger root = loggerContext
.getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(fa);
return loggerContext;
}
示例4: testPrudentModeLogicalImplications
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
@Test
public void testPrudentModeLogicalImplications() {
String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "fat-testPrudentModeLogicalImplications.txt";
File file = new File(filename);
FileAppender<Object> appender = new FileAppender<Object>();
appender.setEncoder(new DummyEncoder<Object>());
appender.setFile(filename);
appender.setName("testPrudentModeLogicalImplications");
appender.setContext(context);
appender.setAppend(false);
appender.setPrudent(true);
appender.start();
assertTrue(appender.isAppend());
StatusManager sm = context.getStatusManager();
//StatusPrinter.print(context);
StatusChecker statusChecker = new StatusChecker(context);
assertEquals(Status.WARN, statusChecker.getHighestLevel(0));
List<Status> statusList = sm.getCopyOfStatusList();
assertTrue("Expecting status list size to be 2 or larger, but was "
+ statusList.size(), statusList.size() >= 2);
String msg1 = statusList.get(1).getMessage();
assertTrue("Got message [" + msg1 + "]", msg1
.startsWith("Setting \"Append\" property"));
appender.doAppend(new Object());
appender.stop();
assertTrue(file.exists());
assertTrue("failed to delete " + file.getAbsolutePath(), file.delete());
}
示例5: buildFileAppender
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
private FileAppender<ILoggingEvent> buildFileAppender(AppenderType type, EncoderBase<ILoggingEvent> encoder, File file) {
FileAppender<ILoggingEvent> appender = this.buildAppender(new FileAppender<>(), type, encoder, false);
appender.setFile(file.getPath());
appender.setPrudent(true);
appender.start();
return appender;
}
示例6: buildFileAppender
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
public static FileAppender<ILoggingEvent> buildFileAppender(LoggingConfiguration.FileConfiguration file,
LoggerContext context,
String logFormat) {
final LogFormatter formatter = new LogFormatter(context, file.getTimeZone());
if (logFormat != null) {
formatter.setPattern(logFormat);
}
formatter.start();
final FileAppender<ILoggingEvent> appender =
file.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
new FileAppender<ILoggingEvent>();
appender.setAppend(true);
appender.setContext(context);
appender.setLayout(formatter);
appender.setFile(file.getCurrentLogFilename());
appender.setPrudent(false);
addThresholdFilter(appender, file.getThreshold());
if (file.isArchive()) {
final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggeringPolicy =
new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
triggeringPolicy.setContext(context);
final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
rollingPolicy.setContext(context);
rollingPolicy.setFileNamePattern(file.getArchivedLogFilenamePattern());
rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(triggeringPolicy);
triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
rollingPolicy.setMaxHistory(file.getArchivedFileCount());
((RollingFileAppender<ILoggingEvent>) appender).setRollingPolicy(rollingPolicy);
((RollingFileAppender<ILoggingEvent>) appender).setTriggeringPolicy(triggeringPolicy);
rollingPolicy.setParent(appender);
rollingPolicy.start();
}
appender.stop();
appender.start();
return appender;
}
示例7: getFileAppender
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
private FileAppender<ILoggingEvent> getFileAppender(final LoggingSettings.LogFile settings,
final LoggerContext context) {
final PatternLayout formatter = getPatternLayout(context);
formatter.setPattern(settings.getLogFormat());
formatter.start();
final FileAppender<ILoggingEvent> appender =
settings.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
new FileAppender<ILoggingEvent>();
appender.setAppend(true);
appender.setContext(context);
appender.setLayout(formatter);
appender.setFile(settings.getCurrentLogFilename());
appender.setPrudent(false);
addThresholdFilter(appender, settings.getThreshold());
if (settings.isArchive()) {
final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggeringPolicy =
new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
triggeringPolicy.setContext(context);
triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
rollingPolicy.setContext(context);
rollingPolicy.setFileNamePattern(settings.getArchivedLogFilenamePattern());
rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(triggeringPolicy);
rollingPolicy.setMaxHistory(settings.getArchivedFileCount());
((RollingFileAppender<ILoggingEvent>)appender).setRollingPolicy(rollingPolicy);
((RollingFileAppender<ILoggingEvent>)appender).setTriggeringPolicy(triggeringPolicy);
rollingPolicy.setParent(appender);
rollingPolicy.start();
}
appender.stop();
appender.start();
return appender;
}
示例8: buildFileAppender
import ch.qos.logback.core.FileAppender; //导入方法依赖的package包/类
public static FileAppender<ILoggingEvent> buildFileAppender(FileLoggingConfiguration file,
LoggerContext context) {
final LogFormatter formatter = new LogFormatter(context, file.getTimeZone());
for (String format : file.getLogFormat().asSet()) {
formatter.setPattern(format);
}
formatter.start();
final FileAppender<ILoggingEvent> appender =
file.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
new FileAppender<ILoggingEvent>();
appender.setAppend(true);
appender.setContext(context);
appender.setLayout(formatter);
appender.setFile(file.getCurrentLogFilename());
appender.setPrudent(false);
addThresholdFilter(appender, file.getThreshold());
if (file.isArchive()) {
final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggeringPolicy =
new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
triggeringPolicy.setContext(context);
final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
rollingPolicy.setContext(context);
rollingPolicy.setFileNamePattern(file.getArchivedLogFilenamePattern());
rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(
triggeringPolicy);
triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
rollingPolicy.setMaxHistory(file.getArchivedFileCount());
((RollingFileAppender<ILoggingEvent>) appender).setRollingPolicy(rollingPolicy);
((RollingFileAppender<ILoggingEvent>) appender).setTriggeringPolicy(triggeringPolicy);
rollingPolicy.setParent(appender);
rollingPolicy.start();
}
appender.stop();
appender.start();
return appender;
}