Class RandomAccessFileManager
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.AbstractManager
-
- org.apache.logging.log4j.core.appender.OutputStreamManager
-
- org.apache.logging.log4j.core.appender.RandomAccessFileManager
-
- All Implemented Interfaces:
java.lang.AutoCloseable,ByteBufferDestination
public class RandomAccessFileManager extends OutputStreamManager
Extends OutputStreamManager 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 classRandomAccessFileManager.FactoryDataFactory Data.private static classRandomAccessFileManager.RandomAccessFileManagerFactoryFactory to create a RandomAccessFileManager.-
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractManager
AbstractManager.AbstractFactoryData
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringadvertiseURI(package private) static intDEFAULT_BUFFER_SIZEprivate static RandomAccessFileManager.RandomAccessFileManagerFactoryFACTORYprivate java.io.RandomAccessFilerandomAccessFile-
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 Modifier Constructor Description protectedRandomAccessFileManager(LoggerContext loggerContext, java.io.RandomAccessFile file, java.lang.String fileName, java.io.OutputStream os, int bufferSize, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, boolean writeHeader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancloseOutputStream()voidflush()Flushes any buffers.intgetBufferSize()Returns the buffer capacity.java.util.Map<java.lang.String,java.lang.String>getContentFormat()Gets this FileManager's content format specified by:static RandomAccessFileManagergetFileManager(java.lang.String fileName, boolean append, boolean immediateFlush, int bufferSize, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, Configuration configuration)Returns the RandomAccessFileManager.java.lang.StringgetFileName()Returns the name of the File being managed.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.protected voidwriteToDestination(byte[] bytes, int offset, int length)Writes the specified section of the specified byte array to the stream.-
Methods inherited from class org.apache.logging.log4j.core.appender.OutputStreamManager
createOutputStream, drain, flushBuffer, flushDestination, getByteBuffer, getManager, getOutputStream, hasOutputStream, isOpen, releaseSub, setOutputStream, skipFooter, write, write, write, write, writeBytes, writeBytes, writeFooter, writeHeader
-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getCount, getLoggerContext, getManager, getManagerCount, getName, getStrSubstitutor, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
FACTORY
private static final RandomAccessFileManager.RandomAccessFileManagerFactory FACTORY
-
advertiseURI
private final java.lang.String advertiseURI
-
randomAccessFile
private final java.io.RandomAccessFile randomAccessFile
-
-
Constructor Detail
-
RandomAccessFileManager
protected RandomAccessFileManager(LoggerContext loggerContext, java.io.RandomAccessFile file, java.lang.String fileName, java.io.OutputStream os, int bufferSize, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, boolean writeHeader)
-
-
Method Detail
-
getFileManager
public static RandomAccessFileManager getFileManager(java.lang.String fileName, boolean append, boolean immediateFlush, int bufferSize, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, Configuration configuration)
Returns the RandomAccessFileManager.- Parameters:
fileName- The name of the file to manage.append- true if the file should be appended to, false if it should be overwritten.immediateFlush- true if the contents should be flushed to disk on every writebufferSize- The buffer size.advertiseURI- the URI to use when advertising the filelayout- The layout.configuration- The configuration.- Returns:
- A RandomAccessFileManager for the File.
-
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.
-
writeToDestination
protected void writeToDestination(byte[] bytes, int offset, int length)Description copied from class:OutputStreamManagerWrites the specified section of the specified byte array to the stream.- Overrides:
writeToDestinationin classOutputStreamManager- Parameters:
bytes- the array containing dataoffset- from where to writelength- how many bytes to write
-
flush
public void flush()
Description copied from class:OutputStreamManagerFlushes any buffers.- Overrides:
flushin classOutputStreamManager
-
closeOutputStream
public boolean closeOutputStream()
- Overrides:
closeOutputStreamin classOutputStreamManager
-
getFileName
public java.lang.String getFileName()
Returns the name of the File being managed.- Returns:
- The name of the File being managed.
-
getBufferSize
public int getBufferSize()
Returns the buffer capacity.- Returns:
- the buffer size
-
getContentFormat
public java.util.Map<java.lang.String,java.lang.String> getContentFormat()
Gets this FileManager's content format specified by:Key: "fileURI" Value: provided "advertiseURI" param.
- Overrides:
getContentFormatin classAbstractManager- Returns:
- Map of content format keys supporting FileManager
-
-