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:
java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RollingRandomAccessFileManager.FactoryData
Factory data.private static class
RollingRandomAccessFileManager.RollingRandomAccessFileManagerFactory
Factory to create a RollingRandomAccessFileManager.-
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractManager
AbstractManager.AbstractFactoryData
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUFFER_SIZE
The default buffer size.private static RollingRandomAccessFileManager.RollingRandomAccessFileManagerFactory
FACTORY
private java.io.RandomAccessFile
randomAccessFile
-
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, java.io.RandomAccessFile raf, java.lang.String fileName, java.lang.String pattern, java.io.OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long time, TriggeringPolicy policy, RolloverStrategy strategy, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, boolean writeHeader)
Deprecated.RollingRandomAccessFileManager(LoggerContext loggerContext, java.io.RandomAccessFile raf, java.lang.String fileName, java.lang.String pattern, java.io.OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long initialTime, TriggeringPolicy policy, RolloverStrategy strategy, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, java.lang.String filePermissions, java.lang.String fileOwner, java.lang.String fileGroup, boolean writeHeader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
closeOutputStream()
protected void
createFileAfterRollover()
private void
createFileAfterRollover(java.lang.String fileName)
void
flush()
Flushes any buffers.int
getBufferSize()
Returns the buffer capacity.static RollingRandomAccessFileManager
getRollingRandomAccessFileManager(java.lang.String fileName, java.lang.String filePattern, boolean isAppend, boolean immediateFlush, int bufferSize, TriggeringPolicy policy, RolloverStrategy strategy, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, java.lang.String filePermissions, java.lang.String fileOwner, java.lang.String fileGroup, Configuration configuration)
java.lang.Boolean
isEndOfBatch()
Deprecated.end-of-batch on the event is used instead.void
setEndOfBatch(boolean endOfBatch)
Deprecated.end-of-batch on the event is used instead.void
updateData(java.lang.Object data)
Updates the RollingFileManager's data during a reconfiguration.protected void
write(byte[] bytes, int offset, int length, boolean immediateFlush)
Some output streams synchronize writes while others do not.private void
writeHeader()
Writes the layout's header to the file if it exists.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
addRolloverListener, checkRollover, createParentDir, getFileExtension, getFileManager, getFileName, getFileSize, getFileTime, getPatternProcessor, getRolloverStrategy, getSemaphore, getTriggeringPolicy, initialize, isDirectWrite, isRenameEmptyFiles, releaseSub, removeRolloverListener, 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, writeHeader
-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getCount, getLoggerContext, getManager, getName, getStrSubstitutor, 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
-
FACTORY
private static final RollingRandomAccessFileManager.RollingRandomAccessFileManagerFactory FACTORY
-
randomAccessFile
private java.io.RandomAccessFile randomAccessFile
-
-
Constructor Detail
-
RollingRandomAccessFileManager
@Deprecated public RollingRandomAccessFileManager(LoggerContext loggerContext, java.io.RandomAccessFile raf, java.lang.String fileName, java.lang.String pattern, java.io.OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long time, TriggeringPolicy policy, RolloverStrategy strategy, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, boolean writeHeader)
Deprecated.
-
RollingRandomAccessFileManager
public RollingRandomAccessFileManager(LoggerContext loggerContext, java.io.RandomAccessFile raf, java.lang.String fileName, java.lang.String pattern, java.io.OutputStream os, boolean append, boolean immediateFlush, int bufferSize, long size, long initialTime, TriggeringPolicy policy, RolloverStrategy strategy, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, java.lang.String filePermissions, java.lang.String fileOwner, java.lang.String fileGroup, boolean writeHeader)
- Since:
- 2.8.3
-
-
Method Detail
-
writeHeader
private void writeHeader()
Writes the layout's header to the file if it exists.
-
getRollingRandomAccessFileManager
public static RollingRandomAccessFileManager getRollingRandomAccessFileManager(java.lang.String fileName, java.lang.String filePattern, boolean isAppend, boolean immediateFlush, int bufferSize, TriggeringPolicy policy, RolloverStrategy strategy, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, java.lang.String filePermissions, java.lang.String fileOwner, java.lang.String fileGroup, Configuration configuration)
-
isEndOfBatch
@Deprecated public java.lang.Boolean isEndOfBatch()
Deprecated.end-of-batch on the event is used instead.No longer used, theLogEvent.isEndOfBatch()
attribute is used instead.- Returns:
Boolean.FALSE
.
-
setEndOfBatch
@Deprecated public void setEndOfBatch(boolean endOfBatch)
Deprecated.end-of-batch on the event is used instead.No longer used, theLogEvent.isEndOfBatch()
attribute is used instead. This method is a no-op.
-
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 java.io.IOException
- Overrides:
createFileAfterRollover
in classRollingFileManager
- Throws:
java.io.IOException
-
createFileAfterRollover
private void createFileAfterRollover(java.lang.String fileName) throws java.io.IOException
- Throws:
java.io.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(java.lang.Object data)
Updates the RollingFileManager's data during a reconfiguration. This method should be considered private. It is not thread safe and calling it outside of a reconfiguration may lead to errors. This method may be made protected in a future release.- Overrides:
updateData
in classRollingFileManager
- Parameters:
data
- The data to update.
-
-