org.jboss.logmanager.handlers.SizeRotatingFileHandler Java Examples
The following examples show how to use
org.jboss.logmanager.handlers.SizeRotatingFileHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SizeRotatingLoggingTest.java From quarkus with Apache License 2.0 | 5 votes |
@Test public void sizeRotatingConfigurationTest() { Handler handler = getHandler(SizeRotatingFileHandler.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"); SizeRotatingFileHandler sizeRotatingFileHandler = (SizeRotatingFileHandler) handler; assertThat(sizeRotatingFileHandler.isRotateOnBoot()).isTrue(); }
Example #2
Source File: LoggingSetupRecorder.java From quarkus with Apache License 2.0 | 5 votes |
private static Handler configureFileHandler(final FileConfig config, final ErrorManager errorManager, final List<LogCleanupFilterElement> filterElements) { FileHandler handler = new FileHandler(); FileConfig.RotationConfig rotationConfig = config.rotation; if ((rotationConfig.maxFileSize.isPresent() || rotationConfig.rotateOnBoot) && rotationConfig.fileSuffix.isPresent()) { PeriodicSizeRotatingFileHandler periodicSizeRotatingFileHandler = new PeriodicSizeRotatingFileHandler(); periodicSizeRotatingFileHandler.setSuffix(rotationConfig.fileSuffix.get()); rotationConfig.maxFileSize .ifPresent(memorySize -> periodicSizeRotatingFileHandler.setRotateSize(memorySize.asLongValue())); periodicSizeRotatingFileHandler.setRotateOnBoot(rotationConfig.rotateOnBoot); periodicSizeRotatingFileHandler.setMaxBackupIndex(rotationConfig.maxBackupIndex); handler = periodicSizeRotatingFileHandler; } else if (rotationConfig.maxFileSize.isPresent()) { SizeRotatingFileHandler sizeRotatingFileHandler = new SizeRotatingFileHandler( rotationConfig.maxFileSize.get().asLongValue(), rotationConfig.maxBackupIndex); sizeRotatingFileHandler.setRotateOnBoot(rotationConfig.rotateOnBoot); handler = sizeRotatingFileHandler; } else if (rotationConfig.fileSuffix.isPresent()) { PeriodicRotatingFileHandler periodicRotatingFileHandler = new PeriodicRotatingFileHandler(); periodicRotatingFileHandler.setSuffix(rotationConfig.fileSuffix.get()); handler = periodicRotatingFileHandler; } 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(new LogCleanupFilter(filterElements)); if (config.async.enable) { return createAsyncHandler(config.async, config.level, handler); } return handler; }
Example #3
Source File: SizeRotatingFileHandlerTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@BeforeClass public static void setup() throws Exception { deploy(createDeployment( createLoggingConfiguration(SizeRotatingFileHandler.class, FILE_NAME, Collections.singletonMap("rotateSize", "5120"))), DEPLOYMENT_NAME); }
Example #4
Source File: SizeRotatingHandlerResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public SizeRotatingHandlerResourceDefinition(final ResolvePathHandler resolvePathHandler, final PathInfoHandler diskUsagePathHandler, final boolean includeLegacyAttributes) { super(SIZE_ROTATING_HANDLER_PATH, SizeRotatingFileHandler.class, resolvePathHandler, diskUsagePathHandler, (includeLegacyAttributes ? Logging.join(ATTRIBUTES, LEGACY_ATTRIBUTES) : ATTRIBUTES)); }