ch.qos.logback.core.rolling.helper.CompressionMode Java Examples
The following examples show how to use
ch.qos.logback.core.rolling.helper.CompressionMode.
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: AppenderUtilsTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testCreateRollingFileAppenderDailyRolling() { final RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>(); AppenderUtils.configureRollingFileAppender(_settings, new LoggerContext(), appender); assertEquals("Unexpected appender file name", _testLogFileName, appender.getFile()); RollingPolicy rollingPolicy = appender.getRollingPolicy(); final boolean condition2 = rollingPolicy instanceof RollingPolicyDecorator; assertTrue("Unexpected rolling policy", condition2); rollingPolicy = ((RollingPolicyDecorator)rollingPolicy).getDecorated(); final boolean condition1 = rollingPolicy instanceof TimeBasedRollingPolicy; assertTrue("Unexpected decorated rolling policy", condition1); assertEquals("Unexpected max history", (long) MAX_HISTORY, (long) ((TimeBasedRollingPolicy) rollingPolicy).getMaxHistory()); assertEquals("Unexpected file name pattern", _testLogFileName + ".%d{yyyy-MM-dd}.%i.gz", ((TimeBasedRollingPolicy) rollingPolicy).getFileNamePattern()); assertEquals("Unexpected compression mode", CompressionMode.GZ, rollingPolicy.getCompressionMode()); TriggeringPolicy triggeringPolicy = ((TimeBasedRollingPolicy) rollingPolicy).getTimeBasedFileNamingAndTriggeringPolicy(); final boolean condition = triggeringPolicy instanceof AppenderUtils.DailyTriggeringPolicy; assertTrue("Unexpected triggering policy", condition); assertEquals("Unexpected triggering policy", String.valueOf(MAX_FILE_SIZE) + " MB", ((AppenderUtils.DailyTriggeringPolicy) triggeringPolicy).getMaxFileSize().toString()); assertEquals("Unexpected layout", LAYOUT, ((PatternLayoutEncoder) appender.getEncoder()).getPattern()); }
Example #2
Source File: AppenderUtilsTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testCreateRollingFileAppenderNonDailyRolling() { when(_settings.isRollDaily()).thenReturn(Boolean.FALSE); when(_settings.isCompressOldFiles()).thenReturn(Boolean.FALSE); RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>(); AppenderUtils.configureRollingFileAppender(_settings, new LoggerContext(), appender); assertEquals("Unexpected appender file name", _testLogFileName, appender.getFile()); RollingPolicy rollingPolicy = appender.getRollingPolicy(); final boolean condition2 = rollingPolicy instanceof RollingPolicyDecorator; assertTrue("Unexpected rolling policy", condition2); rollingPolicy = ((RollingPolicyDecorator)rollingPolicy).getDecorated(); final boolean condition1 = rollingPolicy instanceof AppenderUtils.SimpleRollingPolicy; assertTrue("Unexpected decorated rolling policy", condition1); assertEquals("Unexpected max history", (long) MAX_HISTORY, (long) ((AppenderUtils.SimpleRollingPolicy) rollingPolicy).getMaxIndex()); assertEquals("Unexpected file name pattern", _testLogFileName + ".%i", ((AppenderUtils.SimpleRollingPolicy) rollingPolicy).getFileNamePattern()); assertEquals("Unexpected compression mode", CompressionMode.NONE, rollingPolicy.getCompressionMode()); TriggeringPolicy triggeringPolicy = appender.getTriggeringPolicy(); assertEquals("Unexpected triggering policy", String.valueOf(MAX_FILE_SIZE) + " MB", ((AppenderUtils.SizeTriggeringPolicy) triggeringPolicy).getMaxFileSize().toString()); Encoder encoder = appender.getEncoder(); final boolean condition = encoder instanceof PatternLayoutEncoder; assertTrue("Unexpected encoder", condition); assertEquals("Unexpected layout pattern", LAYOUT, ((PatternLayoutEncoder)encoder).getPattern()); }
Example #3
Source File: NSLogRollingFileAppender.java From ns4_frame with Apache License 2.0 | 4 votes |
public void start() { if (triggeringPolicy == null) { addWarn("No TriggeringPolicy was set for the RollingFileAppender named " + getName()); addWarn("For more information, please visit " + RFA_NO_TP_URL); return; } // we don't want to void existing log files if (!append) { addWarn("Append mode is mandatory for RollingFileAppender"); append = true; } if (rollingPolicy == null) { addError("No RollingPolicy was set for the RollingFileAppender named " + getName()); addError("For more information, please visit " + RFA_NO_RP_URL); return; } // sanity check for http://jira.qos.ch/browse/LOGBACK-796 if (fileAndPatternCollide()) { addError("File property collides with fileNamePattern. Aborting."); addError("For more information, please visit " + COLLISION_URL); return; } if (isPrudent()) { if (rawFileProperty() != null) { addWarn("Setting \"File\" property to null on account of prudent mode"); setFile(null); } if (rollingPolicy.getCompressionMode() != CompressionMode.NONE) { addError("Compression is not supported in prudent mode. Aborting"); return; } } currentlyActiveFile = new File(getFile()); addInfo("Active log file name: " + getFile()); }
Example #4
Source File: RollingPolicyResource.java From orion.server with Eclipse Public License 1.0 | 4 votes |
@PropertyDescription(name = LogConstants.KEY_ROLLING_POLICY_COMPRESSION_MODE) public CompressionMode getCompressionMode() { return compressionMode; }
Example #5
Source File: RollingPolicyResource.java From orion.server with Eclipse Public License 1.0 | 4 votes |
public void setCompressionMode(CompressionMode compressionMode) { this.compressionMode = compressionMode; }
Example #6
Source File: RollingPolicyDecorator.java From qpid-broker-j with Apache License 2.0 | 4 votes |
@Override public CompressionMode getCompressionMode() { return _decorated.getCompressionMode(); }