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 aByteBufferand aRandomAccessFileto do the I/O.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classRollingRandomAccessFileManager.FactoryDataFactory data.private static classRollingRandomAccessFileManager.RollingRandomAccessFileManagerFactoryFactory 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 intDEFAULT_BUFFER_SIZEThe default buffer size.private static RollingRandomAccessFileManager.RollingRandomAccessFileManagerFactoryFACTORYprivate java.io.RandomAccessFilerandomAccessFile-
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 booleancloseOutputStream()protected voidcreateFileAfterRollover()private voidcreateFileAfterRollover(java.lang.String fileName)voidflush()Flushes any buffers.intgetBufferSize()Returns the buffer capacity.static RollingRandomAccessFileManagergetRollingRandomAccessFileManager(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.BooleanisEndOfBatch()Deprecated.end-of-batch on the event is used instead.voidsetEndOfBatch(boolean endOfBatch)Deprecated.end-of-batch on the event is used instead.voidupdateData(java.lang.Object data)Updates the RollingFileManager's data during a reconfiguration.protected voidwrite(byte[] bytes, int offset, int length, boolean immediateFlush)Some output streams synchronize writes while others do not.private voidwriteHeader()Writes the layout's header to the file if it exists.protected voidwriteToDestination(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:OutputStreamManagerSome output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.- Overrides:
writein 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:FileManagerOverridesOutputStreamManager.writeToDestination(byte[], int, int)to add support for file locking.- Overrides:
writeToDestinationin 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:
createFileAfterRolloverin 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:OutputStreamManagerFlushes any buffers.- Overrides:
flushin classOutputStreamManager
-
closeOutputStream
public boolean closeOutputStream()
- Overrides:
closeOutputStreamin classOutputStreamManager
-
getBufferSize
public int getBufferSize()
Returns the buffer capacity.- Overrides:
getBufferSizein 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:
updateDatain classRollingFileManager- Parameters:
data- The data to update.
-
-