use of org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler in project quarkus by quarkusio.
the class PeriodicSizeRotatingLoggingTest method periodicSizeRotatingConfigurationTest.
@Test
public void periodicSizeRotatingConfigurationTest() {
Handler handler = getHandler(PeriodicSizeRotatingFileHandler.class);
assertThat(handler.getLevel()).isEqualTo(Level.INFO);
Formatter formatter = handler.getFormatter();
assertThat(formatter).isInstanceOf(PatternFormatter.class);
PatternFormatter patternFormatter = (PatternFormatter) formatter;
assertThat(patternFormatter.getPattern()).isEqualTo("%d{HH:mm:ss} %-5p [%c{2.}]] (%t) %s%e%n");
PeriodicSizeRotatingFileHandler periodicSizeRotatingFileHandler = (PeriodicSizeRotatingFileHandler) handler;
assertThat(periodicSizeRotatingFileHandler.isRotateOnBoot()).isFalse();
}
use of org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler in project quarkus by quarkusio.
the class LoggingSetupRecorder method configureFileHandler.
private static Handler configureFileHandler(final FileConfig config, final ErrorManager errorManager, final LogCleanupFilter cleanupFilter) {
FileHandler handler;
FileConfig.RotationConfig rotationConfig = config.rotation;
if (rotationConfig.fileSuffix.isPresent()) {
PeriodicSizeRotatingFileHandler periodicSizeRotatingFileHandler = new PeriodicSizeRotatingFileHandler();
periodicSizeRotatingFileHandler.setSuffix(rotationConfig.fileSuffix.get());
periodicSizeRotatingFileHandler.setRotateSize(rotationConfig.maxFileSize.asLongValue());
periodicSizeRotatingFileHandler.setRotateOnBoot(rotationConfig.rotateOnBoot);
periodicSizeRotatingFileHandler.setMaxBackupIndex(rotationConfig.maxBackupIndex);
handler = periodicSizeRotatingFileHandler;
} else {
SizeRotatingFileHandler sizeRotatingFileHandler = new SizeRotatingFileHandler(rotationConfig.maxFileSize.asLongValue(), rotationConfig.maxBackupIndex);
sizeRotatingFileHandler.setRotateOnBoot(rotationConfig.rotateOnBoot);
handler = sizeRotatingFileHandler;
}
final PatternFormatter formatter = new PatternFormatter(config.format);
handler.setFormatter(formatter);
handler.setAppend(true);
try {
handler.setFile(config.path);
} catch (FileNotFoundException e) {
errorManager.error("Failed to set log file", e, ErrorManager.OPEN_FAILURE);
}
handler.setErrorManager(errorManager);
handler.setLevel(config.level);
handler.setFilter(cleanupFilter);
if (config.async.enable) {
return createAsyncHandler(config.async, config.level, handler);
}
return handler;
}
use of org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler in project quarkus by quarkusio.
the class PeriodicSizeRotatingLoggingRotateOnBootTest method periodicSizeRotatingConfigurationTest.
@Test
public void periodicSizeRotatingConfigurationTest() {
Handler handler = getHandler(PeriodicSizeRotatingFileHandler.class);
assertThat(handler.getLevel()).isEqualTo(Level.INFO);
Formatter formatter = handler.getFormatter();
assertThat(formatter).isInstanceOf(PatternFormatter.class);
PatternFormatter patternFormatter = (PatternFormatter) formatter;
assertThat(patternFormatter.getPattern()).isEqualTo("%d{HH:mm:ss} %-5p [%c{2.}]] (%t) %s%e%n");
PeriodicSizeRotatingFileHandler periodicSizeRotatingFileHandler = (PeriodicSizeRotatingFileHandler) handler;
assertThat(periodicSizeRotatingFileHandler.isRotateOnBoot()).isTrue();
}
Aggregations