本文整理匯總了Java中ch.qos.logback.core.rolling.RollingFileAppender.getTriggeringPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Java RollingFileAppender.getTriggeringPolicy方法的具體用法?Java RollingFileAppender.getTriggeringPolicy怎麽用?Java RollingFileAppender.getTriggeringPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ch.qos.logback.core.rolling.RollingFileAppender
的用法示例。
在下文中一共展示了RollingFileAppender.getTriggeringPolicy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: basic
import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
@Test
public void basic() throws Exception {
String testId = "basic";
lc.putProperty("testId", testId);
loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "rolling/" + testId
+ ".xml");
statusChecker.assertIsErrorFree();
Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
expectedFilenameList.add(randomOutputDir + "z" + testId);
RollingFileAppender<ILoggingEvent> rfa = (RollingFileAppender<ILoggingEvent>) root
.getAppender("ROLLING");
TimeBasedRollingPolicy tprp = (TimeBasedRollingPolicy<ILoggingEvent>) rfa
.getTriggeringPolicy();
TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp
.getTimeBasedFileNamingAndTriggeringPolicy();
String prefix = "Hello---";
int runLength = 4;
for (int i = 0; i < runLength; i++) {
logger.debug(prefix + i);
addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbnatp.setCurrentTime(currentTime);
}
existenceCheck(expectedFilenameList);
sortedContentCheck(randomOutputDir, runLength, prefix);
}
示例2: timeAndSize
import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
@Test
public void timeAndSize() throws Exception {
String testId = "timeAndSize";
lc.putProperty("testId", testId);
String prefix = "Hello-----";
// the number of times the log file will be written to before time based
// roll-over occurs
int approxWritesPerPeriod = 64;
sizeThreshold = prefix.length() * approxWritesPerPeriod;
lc.putProperty("sizeThreshold", "" + sizeThreshold);
loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "rolling/" + testId
+ ".xml");
Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
expectedFilenameList.add(randomOutputDir + "z" + testId);
RollingFileAppender<ILoggingEvent> rfa = (RollingFileAppender<ILoggingEvent>) root
.getAppender("ROLLING");
statusChecker.assertIsErrorFree();
TimeBasedRollingPolicy tprp = (TimeBasedRollingPolicy<ILoggingEvent>) rfa
.getTriggeringPolicy();
TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp
.getTimeBasedFileNamingAndTriggeringPolicy();
int timeIncrement = 1000 / approxWritesPerPeriod;
int runLength = approxWritesPerPeriod * 3;
for (int i = 0; i < runLength; i++) {
String msg = prefix + i;
logger.debug(msg);
addExpectedFileNamedIfItsTime(testId, msg, false);
incCurrentTime(timeIncrement);
tbnatp.setCurrentTime(currentTime);
}
sortedContentCheck(randomOutputDir, runLength, prefix);
int eCount = existenceCount(expectedFilenameList);
// for various reasons, it is extremely difficult to have the files
// match exactly the expected archive files. Thus, we aim for
// an approximate match
assertTrue("exitenceCount=" + eCount + ", expectedFilenameList.size="
+ expectedFilenameList.size(), eCount >= 4
&& eCount > expectedFilenameList.size() / 2);
}