Class RollingRandomAccessFileManager
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.AbstractManager
-
- org.apache.logging.log4j.core.appender.OutputStreamManager
-
- org.apache.logging.log4j.core.appender.FileManager
-
- org.apache.logging.log4j.core.appender.rolling.RollingFileManager
-
- org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager
-
- All Implemented Interfaces:
AutoCloseable
,ByteBufferDestination
public class RollingRandomAccessFileManager extends RollingFileManager
Extends RollingFileManager but instead of using a buffered output stream, this class uses aByteBuffer
and aRandomAccessFile
to do the I/O.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUFFER_SIZE
The default buffer size.-
Fields inherited from class org.apache.logging.log4j.core.appender.rolling.RollingFileManager
size
-
Fields inherited from class org.apache.logging.log4j.core.appender.OutputStreamManager
byteBuffer, layout
-
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
-
-
Constructor Summary
Constructors Constructor Description RollingRandomAccessFileManager(LoggerContext loggerContext, RandomAccessFile raf, String fileName, String pattern, OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long time, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, boolean writeHeader)
Deprecated.RollingRandomAccessFileManager(LoggerContext loggerContext, RandomAccessFile raf, String fileName, String pattern, OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long initialTime, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, String filePermissions, String fileOwner, String fileGroup, boolean writeHeader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
closeOutputStream()
protected void
createFileAfterRollover()
void
flush()
Flushes any buffers.int
getBufferSize()
Returns the buffer capacity.static RollingRandomAccessFileManager
getRollingRandomAccessFileManager(String fileName, String filePattern, boolean isAppend, boolean immediateFlush, int bufferSize, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, String filePermissions, String fileOwner, String fileGroup, Configuration configuration)
Boolean
isEndOfBatch()
void
setEndOfBatch(boolean endOfBatch)
void
updateData(Object data)
protected void
write(byte[] bytes, int offset, int length, boolean immediateFlush)
Some output streams synchronize writes while others do not.protected void
writeToDestination(byte[] bytes, int offset, int length)
OverridesOutputStreamManager.writeToDestination(byte[], int, int)
to add support for file locking.-
Methods inherited from class org.apache.logging.log4j.core.appender.rolling.RollingFileManager
checkRollover, getFileExtension, getFileManager, getFileName, getFileSize, getFileTime, getPatternProcessor, getRolloverStrategy, getTriggeringPolicy, initialize, isDirectWrite, isRenameEmptyFiles, releaseSub, rollover, rollover, setPatternProcessor, setRenameEmptyFiles, setRolloverStrategy, setTriggeringPolicy
-
Methods inherited from class org.apache.logging.log4j.core.appender.FileManager
createOutputStream, defineAttributeView, getContentFormat, getFileGroup, getFileManager, getFileOwner, getFilePermissions, isAppend, isAttributeViewEnabled, isCreateOnDemand, isLocking
-
Methods inherited from class org.apache.logging.log4j.core.appender.OutputStreamManager
drain, flushBuffer, flushDestination, getByteBuffer, getManager, getOutputStream, hasOutputStream, isOpen, setOutputStream, skipFooter, write, write, write, writeBytes, writeBytes, writeFooter
-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getCount, getLoggerContext, getManager, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
The default buffer size.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RollingRandomAccessFileManager
@Deprecated public RollingRandomAccessFileManager(LoggerContext loggerContext, RandomAccessFile raf, String fileName, String pattern, OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long time, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, boolean writeHeader)
Deprecated.
-
RollingRandomAccessFileManager
public RollingRandomAccessFileManager(LoggerContext loggerContext, RandomAccessFile raf, String fileName, String pattern, OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long initialTime, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, String filePermissions, String fileOwner, String fileGroup, boolean writeHeader)
- Since:
- 2.8.3
-
-
Method Detail
-
getRollingRandomAccessFileManager
public static RollingRandomAccessFileManager getRollingRandomAccessFileManager(String fileName, String filePattern, boolean isAppend, boolean immediateFlush, int bufferSize, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, String filePermissions, String fileOwner, String fileGroup, Configuration configuration)
-
isEndOfBatch
public Boolean isEndOfBatch()
-
setEndOfBatch
public void setEndOfBatch(boolean endOfBatch)
-
write
protected void write(byte[] bytes, int offset, int length, boolean immediateFlush)
Description copied from class:OutputStreamManager
Some output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.- Overrides:
write
in classRollingFileManager
- Parameters:
bytes
- The serialized Log event.offset
- The offset into the byte array.length
- The number of bytes to write.immediateFlush
- flushes immediately after writing.
-
writeToDestination
protected void writeToDestination(byte[] bytes, int offset, int length)
Description copied from class:FileManager
OverridesOutputStreamManager.writeToDestination(byte[], int, int)
to add support for file locking.- Overrides:
writeToDestination
in classRollingFileManager
- Parameters:
bytes
- the array containing dataoffset
- from where to writelength
- how many bytes to write
-
createFileAfterRollover
protected void createFileAfterRollover() throws IOException
- Overrides:
createFileAfterRollover
in classRollingFileManager
- Throws:
IOException
-
flush
public void flush()
Description copied from class:OutputStreamManager
Flushes any buffers.- Overrides:
flush
in classOutputStreamManager
-
closeOutputStream
public boolean closeOutputStream()
- Overrides:
closeOutputStream
in classOutputStreamManager
-
getBufferSize
public int getBufferSize()
Returns the buffer capacity.- Overrides:
getBufferSize
in classFileManager
- Returns:
- the buffer size
-
updateData
public void updateData(Object data)
- Overrides:
updateData
in classRollingFileManager
-
-