Package edu.wisc.ssec.mcidasv.util
Class TailFriendlyRollingPolicy<E>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.rolling.RollingPolicyBase
ch.qos.logback.core.rolling.TimeBasedRollingPolicy<E>
edu.wisc.ssec.mcidasv.util.TailFriendlyRollingPolicy<E>
- All Implemented Interfaces:
ch.qos.logback.core.rolling.RollingPolicy,ch.qos.logback.core.rolling.TriggeringPolicy<E>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.LifeCycle
public class TailFriendlyRollingPolicy<E>
extends ch.qos.logback.core.rolling.TimeBasedRollingPolicy<E>
This Logback "rolling policy" copies the contents of a log file
(in this case, mcidasv.log) to the specified destination, and then
"zeroes out" the original log file. This approach allows McIDAS-V
users to run a command like "tail -f mcidasv.log" without any
issue. Even on Windows.
-
Field Summary
FieldsFields inherited from class ch.qos.logback.core.rolling.TimeBasedRollingPolicy
totalSizeCapFields inherited from class ch.qos.logback.core.rolling.RollingPolicyBase
compressionMode, fileNamePatternStrFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Future<?> asyncCompress(String uncompressedPath, String compressedPath, String innerEntryName) private static booleanisFileEmpty(String filepath) Determine if the file at the given path is zero length.voidrenameByCopying(String src, String target) Copies the contents ofsrcintotarget, and then "zeroes out"src.(package private) Future<?> renamedRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName) voidrollover()Methods inherited from class ch.qos.logback.core.rolling.TimeBasedRollingPolicy
getActiveFileName, getLengthCounter, getMaxHistory, getTimeBasedFileNamingAndTriggeringPolicy, isCleanHistoryOnStart, isTriggeringEvent, isUnboundedTotalSizeCap, setCleanHistoryOnStart, setMaxHistory, setTimeBasedFileNamingAndTriggeringPolicy, setTotalSizeCap, start, stop, toStringMethods inherited from class ch.qos.logback.core.rolling.RollingPolicyBase
adjustCompressionModeAndFileNamePatternStrIfNecessary, determineCompressionMode, getCompressionMode, getFileNamePattern, getParentsRawFileProperty, isParentPrudent, isStarted, setFileNamePattern, setParentMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.LifeCycle
isStarted
-
Field Details
-
future
-
-
Constructor Details
-
TailFriendlyRollingPolicy
public TailFriendlyRollingPolicy()
-
-
Method Details
-
rollover
- Specified by:
rolloverin interfacech.qos.logback.core.rolling.RollingPolicy- Overrides:
rolloverin classch.qos.logback.core.rolling.TimeBasedRollingPolicy<E>- Throws:
ch.qos.logback.core.rolling.RolloverFailure
-
asyncCompress
Future<?> asyncCompress(String uncompressedPath, String compressedPath, String innerEntryName) throws ch.qos.logback.core.rolling.RolloverFailure - Throws:
ch.qos.logback.core.rolling.RolloverFailure
-
renamedRawAndAsyncCompress
Future<?> renamedRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName) throws ch.qos.logback.core.rolling.RolloverFailure - Throws:
ch.qos.logback.core.rolling.RolloverFailure
-
renameByCopying
public void renameByCopying(String src, String target) throws ch.qos.logback.core.rolling.RolloverFailure Copies the contents ofsrcintotarget, and then "zeroes out"src.- Parameters:
src- Path to the file to be copied. Cannot benull.target- Path to the destination file. Cannot benull.- Throws:
ch.qos.logback.core.rolling.RolloverFailure- if copying failed.
-
isFileEmpty
Determine if the file at the given path is zero length.- Parameters:
filepath- Path to the file to be tested. Cannot benull.- Returns:
trueiffilepathexists and is empty.
-