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
Extends RollingFileManager but instead of using a buffered output stream, this class uses a
ByteBuffer and a
RandomAccessFile to do the I/O.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractManager
AbstractManager.AbstractFactoryData -
Field Summary
FieldsFields inherited from class org.apache.logging.log4j.core.appender.rolling.RollingFileManager
sizeFields inherited from class org.apache.logging.log4j.core.appender.OutputStreamManager
byteBuffer, layoutFields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER -
Constructor Summary
ConstructorsConstructorDescriptionRollingRandomAccessFileManager(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
Modifier and TypeMethodDescriptionbooleanprotected voidvoidflush()Flushes any buffers.intReturns the buffer capacity.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) Deprecated.end-of-batch on the event is used instead.voidsetEndOfBatch(boolean endOfBatch) Deprecated.end-of-batch on the event is used instead.voidupdateData(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.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, getTriggeringPolicy, initialize, isDirectWrite, isRenameEmptyFiles, releaseSub, removeRolloverListener, rollover, rollover, setPatternProcessor, setRenameEmptyFiles, setRolloverStrategy, setTriggeringPolicyMethods inherited from class org.apache.logging.log4j.core.appender.FileManager
createOutputStream, defineAttributeView, getContentFormat, getFileGroup, getFileManager, getFileOwner, getFilePermissions, isAppend, isAttributeViewEnabled, isCreateOnDemand, isLockingMethods 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, writeHeaderMethods 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 Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default buffer size.- See Also:
-
-
Constructor Details
-
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 Details
-
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
Deprecated.end-of-batch on the event is used instead.No longer used, theLogEvent.isEndOfBatch()attribute is used instead.- Returns:
Boolean.FALSE.
-
setEndOfBatch
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
- Overrides:
createFileAfterRolloverin classRollingFileManager- Throws:
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
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.
-