Package org.omegazero.common.logging
Class RotatingFileLoggerOutput
java.lang.Object
org.omegazero.common.logging.FileLoggerOutput
org.omegazero.common.logging.RotatingFileLoggerOutput
- All Implemented Interfaces:
LoggerOutput
A
FileLoggerOutput
with support for log rotation.- Since:
- 2.11.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
System propertyorg.omegazero.common.logging.rotation.checkTimeout
static final long
System propertyorg.omegazero.common.logging.rotation.maxFileSize
Fields inherited from class org.omegazero.common.logging.FileLoggerOutput
LOG_BUFFER_BYTES, SAVE_INTERVAL, SYNC_FLUSH_DEFAULT, writer
-
Constructor Summary
ConstructorsConstructorDescriptionRotatingFileLoggerOutput
(String logFile, long maxFileSize) Creates a newRotatingFileLoggerOutput
, writing to the givenlogFile
.RotatingFileLoggerOutput
(String logFile, long maxFileSize, int logBufferBytes, int saveInterval) Creates a newRotatingFileLoggerOutput
, writing to the givenlogFile
. -
Method Summary
Methods inherited from class org.omegazero.common.logging.FileLoggerOutput
close, getLogFile, reopen, setSyncFlush
-
Field Details
-
MAX_FILE_SIZE_DEFAULT
public static final long MAX_FILE_SIZE_DEFAULTSystem propertyorg.omegazero.common.logging.rotation.maxFileSize
The default maximum file size for rotation.
Default:
0
(log rotation disabled) -
CHECK_TIMEOUT
public static final long CHECK_TIMEOUTSystem propertyorg.omegazero.common.logging.rotation.checkTimeout
The time in seconds between rotation checks.
Default:
60
-
-
Constructor Details
-
RotatingFileLoggerOutput
Creates a newRotatingFileLoggerOutput
, writing to the givenlogFile
.- Parameters:
logFile
- The name of the output log filemaxFileSize
- The maximum file size for rotation. If this value is negative, thedefault
is used; if0
, log rotation is disabled- Throws:
IOException
- If an IO error occurs while opening the file- See Also:
-
RotatingFileLoggerOutput
public RotatingFileLoggerOutput(String logFile, long maxFileSize, int logBufferBytes, int saveInterval) throws IOException Creates a newRotatingFileLoggerOutput
, writing to the givenlogFile
.The maximum file size parameter is not a hard limit on the file size of log files. If the log file exceeds this size, it is rotated, but the file may end up larger than this parameter, especially if there is a lot of log output in a short time.
- Parameters:
logFile
- The name of the output log filemaxFileSize
- The maximum file size for rotation. If this value is negative, thedefault
is used; if0
, log rotation is disabledlogBufferBytes
- The size of the internal log data buffersaveInterval
- The save interval- Throws:
IOException
- If an IO error occurs while opening the file- See Also:
-
-
Method Details
-
writeLine
Description copied from interface:LoggerOutput
Writes the given log line to thisLoggerOutput
.- Specified by:
writeLine
in interfaceLoggerOutput
- Overrides:
writeLine
in classFileLoggerOutput
- Parameters:
line
- The log messagemarkup
- Special terminal escape sequences used for text markup
-
flush
public void flush()Description copied from interface:LoggerOutput
Flushes any buffered data to the underlying output.- Specified by:
flush
in interfaceLoggerOutput
- Overrides:
flush
in classFileLoggerOutput
-