Package org.jpos.util
Class DailyLogListener
- java.lang.Object
-
- org.jpos.util.SimpleLogListener
-
- org.jpos.util.RotateLogListener
-
- org.jpos.util.DailyLogListener
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.util.EventListener
,java.util.function.Consumer<LogEventWriter>
,Configurable
,XmlConfigurable
,Destroyable
,LogListener
public class DailyLogListener extends RotateLogListener
Rotates log daily and compress the previous log.- Since:
- jPOS 1.5.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
DailyLogListener.Compressor
-
Nested classes/interfaces inherited from class org.jpos.util.RotateLogListener
RotateLogListener.Rotate
-
-
Field Summary
-
Fields inherited from class org.jpos.util.RotateLogListener
CHECK_INTERVAL, DEFAULT_MAXSIZE
-
-
Constructor Summary
Constructors Constructor Description DailyLogListener()
Creates a new instance of DailyLogListener
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeCompressedOutputStream(java.io.OutputStream os)
protected void
compress(java.io.File logFile)
Hook method to optionally compress the filevoid
deleteOldLogs()
protected java.io.OutputStream
getCompressedOutputStream(java.io.File f)
Hook method that creates an output stream that will compress the data.java.lang.String
getCompressedSuffix()
Getter for property compressedExt.int
getCompressionBufferSize()
Getter for property compressionBufferSize.int
getCompressionFormat()
Getter for property compressionFormat.protected java.lang.Thread
getCompressorThread(java.io.File f)
Hook method that creates a thread to compress the file f.java.text.DateFormat
getDateFmt()
Getter for property dateFmt.java.lang.String
getDeleteRegex()
Getter for property deleteRegex.java.lang.String
getLastDate()
Getter for property lastDate.long
getMaxAge()
Getter for property maxAge.java.lang.String
getPrefix()
Getter for property prefix.int
getRotateCount()
Getter for property rotateCount.java.lang.String
getSuffix()
Getter for property suffix.protected void
logDebugEx(java.lang.String msg, java.lang.Throwable e)
void
setCompressedSuffix(java.lang.String compressedSuffix)
Setter for property compressedExt.void
setCompressionBufferSize(int compressionBufferSize)
Setter for property compressionBufferSize.void
setCompressionFormat(int compressionFormat)
Setter for property compressionFormat.void
setConfiguration(Configuration cfg)
Configure this RotateLogListener
Properties:
file base log filename [window] in seconds (default 0 - never rotate) [count] number of copies (default 0 == single copy) [maxsize] max log size in bytes (approx) [rotate-on-startup] Rotate file on q2 startup (default: false) [file-name-pattern] Comma-delimited codes for positional token replacement (case sensitive)void
setDateFmt(java.text.DateFormat dateFmt)
Setter for property dateFmt.void
setDeleteRegex(java.lang.String deleteRegex)
Setter for property deleteRegex.void
setLastDate(java.lang.String lastDate)
Setter for property lastDate.void
setMaxAge(long maxAge)
Setter for property maxAge.void
setPrefix(java.lang.String prefix)
Setter for property prefix.void
setRotateCount(int rotateCount)
Setter for property rotateCount.void
setSuffix(java.lang.String suffix)
Setter for property suffix.-
Methods inherited from class org.jpos.util.RotateLogListener
checkSize, closeLogFile, destroy, fileNameFromPattern, log, logDebug, logRotate, logRotate, openLogFile
-
Methods inherited from class org.jpos.util.SimpleLogListener
accept, close, setConfiguration, setPrintStream
-
-
-
-
Constructor Detail
-
DailyLogListener
public DailyLogListener()
Creates a new instance of DailyLogListener
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration cfg) throws ConfigurationException
Description copied from class:RotateLogListener
Configure this RotateLogListener
Properties:
- file base log filename
- [window] in seconds (default 0 - never rotate)
- [count] number of copies (default 0 == single copy)
- [maxsize] max log size in bytes (approx)
- [rotate-on-startup] Rotate file on q2 startup (default: false)
- [file-name-pattern] Comma-delimited codes for positional token replacement (case sensitive)
Currently supported file-pattern-codes:
- h - hostname lookup
When code replacement fails, the token will be replaced by the code preceded by a # to give an indication of what failed. This type of failure will not result in a startup failure.
file is expected to contain %s tokens for replacement when enabled, as expected by String.format.
- Specified by:
setConfiguration
in interfaceConfigurable
- Overrides:
setConfiguration
in classRotateLogListener
- Parameters:
cfg
- Configuration- Throws:
ConfigurationException
-
deleteOldLogs
public void deleteOldLogs() throws java.io.IOException
- Throws:
java.io.IOException
-
getSuffix
public java.lang.String getSuffix()
Getter for property suffix.- Returns:
- Value of property suffix.
-
setSuffix
public void setSuffix(java.lang.String suffix)
Setter for property suffix.- Parameters:
suffix
- New value of property suffix.
-
getPrefix
public java.lang.String getPrefix()
Getter for property prefix.- Returns:
- Value of property prefix.
-
setPrefix
public void setPrefix(java.lang.String prefix)
Setter for property prefix.- Parameters:
prefix
- New value of property prefix.
-
getRotateCount
public int getRotateCount()
Getter for property rotateCount.- Returns:
- Value of property rotateCount.
-
setRotateCount
public void setRotateCount(int rotateCount)
Setter for property rotateCount.- Parameters:
rotateCount
- New value of property rotateCount.
-
getDateFmt
public java.text.DateFormat getDateFmt()
Getter for property dateFmt.- Returns:
- Value of property dateFmt.
-
setDateFmt
public void setDateFmt(java.text.DateFormat dateFmt)
Setter for property dateFmt.- Parameters:
dateFmt
- New value of property dateFmt.
-
getLastDate
public java.lang.String getLastDate()
Getter for property lastDate.- Returns:
- Value of property lastDate.
-
setLastDate
public void setLastDate(java.lang.String lastDate)
Setter for property lastDate.- Parameters:
lastDate
- New value of property lastDate.
-
getCompressedSuffix
public java.lang.String getCompressedSuffix()
Getter for property compressedExt.- Returns:
- Value of property compressedExt.
-
setCompressedSuffix
public void setCompressedSuffix(java.lang.String compressedSuffix)
Setter for property compressedExt.- Parameters:
compressedSuffix
- New value of property compressedExt.
-
getMaxAge
public long getMaxAge()
Getter for property maxAge.- Returns:
- Value of property maxAge.
-
setMaxAge
public void setMaxAge(long maxAge)
Setter for property maxAge.- Parameters:
maxAge
- new value of property maxAge.
-
getDeleteRegex
public java.lang.String getDeleteRegex()
Getter for property deleteRegex.- Returns:
- Value of property deleteRegex.
-
setDeleteRegex
public void setDeleteRegex(java.lang.String deleteRegex)
Setter for property deleteRegex.- Parameters:
deleteRegex
- new value of property deleteRegex.
-
getCompressorThread
protected java.lang.Thread getCompressorThread(java.io.File f)
Hook method that creates a thread to compress the file f.- Parameters:
f
- the file name- Returns:
- a thread to compress the file and null if it is not necessary
-
getCompressedOutputStream
protected java.io.OutputStream getCompressedOutputStream(java.io.File f) throws java.io.IOException
Hook method that creates an output stream that will compress the data.- Parameters:
f
- the file name- Returns:
- ZIP/GZip OutputStream
- Throws:
java.io.IOException
- on error
-
closeCompressedOutputStream
protected void closeCompressedOutputStream(java.io.OutputStream os) throws java.io.IOException
- Throws:
java.io.IOException
-
logDebugEx
protected void logDebugEx(java.lang.String msg, java.lang.Throwable e)
-
getCompressionFormat
public int getCompressionFormat()
Getter for property compressionFormat.- Returns:
- Value of property compressionFormat.
-
setCompressionFormat
public void setCompressionFormat(int compressionFormat)
Setter for property compressionFormat.- Parameters:
compressionFormat
- New value of property compressionFormat.
-
getCompressionBufferSize
public int getCompressionBufferSize()
Getter for property compressionBufferSize.- Returns:
- Value of property compressionBufferSize.
-
setCompressionBufferSize
public void setCompressionBufferSize(int compressionBufferSize)
Setter for property compressionBufferSize.- Parameters:
compressionBufferSize
- New value of property compressionBufferSize.
-
compress
protected void compress(java.io.File logFile)
Hook method to optionally compress the file- Parameters:
logFile
- the file name
-
-