Package org.jpos.util
Class RotateLogListener
- java.lang.Object
-
- org.jpos.util.SimpleLogListener
-
- org.jpos.util.RotateLogListener
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.util.EventListener
,java.util.function.Consumer<LogEventWriter>
,Configurable
,XmlConfigurable
,Destroyable
,LogListener
- Direct Known Subclasses:
DailyLogListener
public class RotateLogListener extends SimpleLogListener implements java.lang.AutoCloseable, Configurable, Destroyable
Rotates logs- Since:
- jPOS 1.2
- See Also:
Configurable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
RotateLogListener.Rotate
-
Field Summary
Fields Modifier and Type Field Description static int
CHECK_INTERVAL
static long
DEFAULT_MAXSIZE
-
Constructor Summary
Constructors Constructor Description RotateLogListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkSize()
protected void
closeLogFile()
void
destroy()
protected java.lang.String
fileNameFromPattern(java.lang.String inFileName, java.lang.String patternCodes)
LogEvent
log(LogEvent ev)
protected void
logDebug(java.lang.String msg)
void
logRotate()
void
logRotate(boolean isStartup)
protected void
openLogFile()
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)-
Methods inherited from class org.jpos.util.SimpleLogListener
accept, close, setConfiguration, setPrintStream
-
-
-
-
Field Detail
-
CHECK_INTERVAL
public static final int CHECK_INTERVAL
- See Also:
- Constant Field Values
-
DEFAULT_MAXSIZE
public static final long DEFAULT_MAXSIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RotateLogListener
public RotateLogListener()
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration cfg) throws ConfigurationException
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
- Parameters:
cfg
- Configuration- Throws:
ConfigurationException
-
log
public LogEvent log(LogEvent ev)
- Specified by:
log
in interfaceLogListener
- Overrides:
log
in classSimpleLogListener
-
openLogFile
protected void openLogFile() throws java.io.IOException
- Throws:
java.io.IOException
-
closeLogFile
protected void closeLogFile() throws java.io.IOException
- Throws:
java.io.IOException
-
logRotate
public void logRotate() throws java.io.IOException
- Throws:
java.io.IOException
-
logRotate
public void logRotate(boolean isStartup) throws java.io.IOException
- Throws:
java.io.IOException
-
logDebug
protected void logDebug(java.lang.String msg)
-
checkSize
protected void checkSize()
-
fileNameFromPattern
protected java.lang.String fileNameFromPattern(java.lang.String inFileName, java.lang.String patternCodes)
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceDestroyable
-
-