Class GzCompressAction
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
-
- org.apache.logging.log4j.core.appender.rolling.action.GzCompressAction
-
- All Implemented Interfaces:
java.lang.Runnable
,Action
public final class GzCompressAction extends AbstractAction
Compresses a file using GZ compression.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GzCompressAction.ConfigurableLevelGZIPOutputStream
-
Field Summary
Fields Modifier and Type Field Description private static int
BUF_SIZE
private int
compressionLevel
GZIP compression level to use.private boolean
deleteSource
If true, attempt to delete file on completion.private java.io.File
destination
Destination file.private java.io.File
source
Source file.-
Fields inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
LOGGER
-
-
Constructor Summary
Constructors Constructor Description GzCompressAction(java.io.File source, java.io.File destination, boolean deleteSource)
Deprecated.GzCompressAction(java.io.File source, java.io.File destination, boolean deleteSource, int compressionLevel)
Create new instance of GzCompressAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
execute()
Compress.static boolean
execute(java.io.File source, java.io.File destination, boolean deleteSource)
Deprecated.In favor ofexecute(File, File, boolean, int)
.static boolean
execute(java.io.File source, java.io.File destination, boolean deleteSource, int compressionLevel)
Compress a file.java.io.File
getDestination()
java.io.File
getSource()
boolean
isDeleteSource()
protected void
reportException(java.lang.Exception ex)
Capture exception.java.lang.String
toString()
-
Methods inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
close, isComplete, isInterrupted, run
-
-
-
-
Field Detail
-
BUF_SIZE
private static final int BUF_SIZE
- See Also:
- Constant Field Values
-
source
private final java.io.File source
Source file.
-
destination
private final java.io.File destination
Destination file.
-
deleteSource
private final boolean deleteSource
If true, attempt to delete file on completion.
-
compressionLevel
private final int compressionLevel
GZIP compression level to use.- See Also:
Deflater.setLevel(int)
-
-
Constructor Detail
-
GzCompressAction
public GzCompressAction(java.io.File source, java.io.File destination, boolean deleteSource, int compressionLevel)
Create new instance of GzCompressAction.- Parameters:
source
- file to compress, may not be null.destination
- compressed file, may not be null.deleteSource
- if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.compressionLevel
- Gzip deflater compression level.
-
GzCompressAction
@Deprecated public GzCompressAction(java.io.File source, java.io.File destination, boolean deleteSource)
Deprecated.Prefer the constructor with compression level.
-
-
Method Detail
-
execute
public boolean execute() throws java.io.IOException
Compress.- Specified by:
execute
in interfaceAction
- Specified by:
execute
in classAbstractAction
- Returns:
- true if successfully compressed.
- Throws:
java.io.IOException
- on IO exception.
-
execute
@Deprecated public static boolean execute(java.io.File source, java.io.File destination, boolean deleteSource) throws java.io.IOException
Deprecated.In favor ofexecute(File, File, boolean, int)
.Compress a file.- Parameters:
source
- file to compress, may not be null.destination
- compressed file, may not be null.deleteSource
- if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.- Returns:
- true if source file compressed.
- Throws:
java.io.IOException
- on IO exception.
-
execute
public static boolean execute(java.io.File source, java.io.File destination, boolean deleteSource, int compressionLevel) throws java.io.IOException
Compress a file.- Parameters:
source
- file to compress, may not be null.destination
- compressed file, may not be null.deleteSource
- if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.compressionLevel
- Gzip deflater compression level.- Returns:
- true if source file compressed.
- Throws:
java.io.IOException
- on IO exception.
-
reportException
protected void reportException(java.lang.Exception ex)
Capture exception.- Overrides:
reportException
in classAbstractAction
- Parameters:
ex
- exception.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getSource
public java.io.File getSource()
-
getDestination
public java.io.File getDestination()
-
isDeleteSource
public boolean isDeleteSource()
-
-