public class RollingFileManager extends FileManager
Modifier and Type | Field and Description |
---|---|
protected long |
size |
byteBuffer, layout
count, LOGGER
Modifier | Constructor and Description |
---|---|
protected |
RollingFileManager(LoggerContext loggerContext,
String fileName,
String pattern,
OutputStream os,
boolean append,
boolean createOnDemand,
long size,
long initialTime,
TriggeringPolicy triggeringPolicy,
RolloverStrategy rolloverStrategy,
String advertiseURI,
Layout<? extends Serializable> layout,
boolean writeHeader,
ByteBuffer buffer)
Deprecated.
|
protected |
RollingFileManager(LoggerContext loggerContext,
String fileName,
String pattern,
OutputStream os,
boolean append,
boolean createOnDemand,
long size,
long initialTime,
TriggeringPolicy triggeringPolicy,
RolloverStrategy rolloverStrategy,
String advertiseURI,
Layout<? extends Serializable> layout,
String filePermissions,
String fileOwner,
String fileGroup,
boolean writeHeader,
ByteBuffer buffer) |
protected |
RollingFileManager(String fileName,
String pattern,
OutputStream os,
boolean append,
long size,
long initialTime,
TriggeringPolicy triggeringPolicy,
RolloverStrategy rolloverStrategy,
String advertiseURI,
Layout<? extends Serializable> layout,
boolean writeHeader,
ByteBuffer buffer)
Deprecated.
|
protected |
RollingFileManager(String fileName,
String pattern,
OutputStream os,
boolean append,
long size,
long initialTime,
TriggeringPolicy triggeringPolicy,
RolloverStrategy rolloverStrategy,
String advertiseURI,
Layout<? extends Serializable> layout,
int bufferSize,
boolean writeHeader)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addRolloverListener(RolloverListener listener)
Add a RolloverListener.
|
void |
checkRollover(LogEvent event)
Determines if a rollover should occur.
|
protected void |
createFileAfterRollover() |
protected void |
createParentDir(File file) |
FileExtension |
getFileExtension() |
static RollingFileManager |
getFileManager(String fileName,
String pattern,
boolean append,
boolean bufferedIO,
TriggeringPolicy policy,
RolloverStrategy strategy,
String advertiseURI,
Layout<? extends Serializable> layout,
int bufferSize,
boolean immediateFlush,
boolean createOnDemand,
String filePermissions,
String fileOwner,
String fileGroup,
Configuration configuration)
Returns a RollingFileManager.
|
String |
getFileName()
Returns the name of the File being managed.
|
long |
getFileSize()
Returns the current size of the file.
|
long |
getFileTime()
Returns the time the file was created.
|
PatternProcessor |
getPatternProcessor()
Returns the pattern processor.
|
RolloverStrategy |
getRolloverStrategy()
Returns the rollover strategy.
|
<T extends TriggeringPolicy> |
getTriggeringPolicy()
Returns the triggering policy.
|
void |
initialize() |
boolean |
isDirectWrite() |
boolean |
isRenameEmptyFiles() |
boolean |
releaseSub(long timeout,
TimeUnit timeUnit)
Default hook to write footer during close.
|
void |
removeRolloverListener(RolloverListener listener)
Remove a RolloverListener.
|
void |
rollover() |
void |
rollover(Date prevFileTime,
Date prevRollTime) |
void |
setPatternProcessor(PatternProcessor patternProcessor) |
void |
setRenameEmptyFiles(boolean renameEmptyFiles) |
void |
setRolloverStrategy(RolloverStrategy rolloverStrategy) |
void |
setTriggeringPolicy(TriggeringPolicy triggeringPolicy) |
void |
updateData(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.
|
protected void |
writeToDestination(byte[] bytes,
int offset,
int length)
Overrides
OutputStreamManager.writeToDestination(byte[], int, int) to add support for file locking. |
createOutputStream, defineAttributeView, getBufferSize, getContentFormat, getFileGroup, getFileManager, getFileOwner, getFilePermissions, isAppend, isAttributeViewEnabled, isCreateOnDemand, isLocking
closeOutputStream, drain, flush, flushBuffer, flushDestination, getByteBuffer, getManager, getOutputStream, hasOutputStream, isOpen, setOutputStream, skipFooter, write, write, write, writeBytes, writeBytes, writeFooter, writeHeader
close, getCount, getLoggerContext, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop
protected long size
@Deprecated protected RollingFileManager(String fileName, String pattern, OutputStream os, boolean append, long size, long initialTime, TriggeringPolicy triggeringPolicy, RolloverStrategy rolloverStrategy, String advertiseURI, Layout<? extends Serializable> layout, int bufferSize, boolean writeHeader)
@Deprecated protected RollingFileManager(String fileName, String pattern, OutputStream os, boolean append, long size, long initialTime, TriggeringPolicy triggeringPolicy, RolloverStrategy rolloverStrategy, String advertiseURI, Layout<? extends Serializable> layout, boolean writeHeader, ByteBuffer buffer)
@Deprecated protected RollingFileManager(LoggerContext loggerContext, String fileName, String pattern, OutputStream os, boolean append, boolean createOnDemand, long size, long initialTime, TriggeringPolicy triggeringPolicy, RolloverStrategy rolloverStrategy, String advertiseURI, Layout<? extends Serializable> layout, boolean writeHeader, ByteBuffer buffer)
protected RollingFileManager(LoggerContext loggerContext, String fileName, String pattern, OutputStream os, boolean append, boolean createOnDemand, long size, long initialTime, TriggeringPolicy triggeringPolicy, RolloverStrategy rolloverStrategy, String advertiseURI, Layout<? extends Serializable> layout, String filePermissions, String fileOwner, String fileGroup, boolean writeHeader, ByteBuffer buffer)
public void initialize()
public static RollingFileManager getFileManager(String fileName, String pattern, boolean append, boolean bufferedIO, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, int bufferSize, boolean immediateFlush, boolean createOnDemand, String filePermissions, String fileOwner, String fileGroup, Configuration configuration)
fileName
- The file name.pattern
- The pattern for rolling file.append
- true if the file should be appended to.bufferedIO
- true if data should be buffered.policy
- The TriggeringPolicy.strategy
- The RolloverStrategy.advertiseURI
- the URI to use when advertising the filelayout
- The Layout.bufferSize
- buffer size to use if bufferedIO is trueimmediateFlush
- flush on every write or notcreateOnDemand
- true if you want to lazy-create the file (a.k.a. on-demand.)filePermissions
- File permissionsfileOwner
- File ownerfileGroup
- File groupconfiguration
- The configuration.public void addRolloverListener(RolloverListener listener)
listener
- The RolloverListener.public void removeRolloverListener(RolloverListener listener)
listener
- The RolloverListener.public String getFileName()
getFileName
in class FileManager
protected void createParentDir(File file)
createParentDir
in class FileManager
public boolean isDirectWrite()
public FileExtension getFileExtension()
protected void write(byte[] bytes, int offset, int length, boolean immediateFlush)
OutputStreamManager
write
in class FileManager
bytes
- The serialized Log event.offset
- The offset into the byte array.length
- The number of bytes to write.immediateFlush
- flushes immediately after writing.protected void writeToDestination(byte[] bytes, int offset, int length)
FileManager
OutputStreamManager.writeToDestination(byte[], int, int)
to add support for file locking.writeToDestination
in class FileManager
bytes
- the array containing dataoffset
- from where to writelength
- how many bytes to writepublic boolean isRenameEmptyFiles()
public void setRenameEmptyFiles(boolean renameEmptyFiles)
public long getFileSize()
public long getFileTime()
public void checkRollover(LogEvent event)
event
- The LogEvent.public boolean releaseSub(long timeout, TimeUnit timeUnit)
OutputStreamManager
releaseSub
in class OutputStreamManager
timeout
- timeouttimeUnit
- timeout time unitpublic void rollover()
protected void createFileAfterRollover() throws IOException
IOException
public PatternProcessor getPatternProcessor()
public void setTriggeringPolicy(TriggeringPolicy triggeringPolicy)
public void setRolloverStrategy(RolloverStrategy rolloverStrategy)
public void setPatternProcessor(PatternProcessor patternProcessor)
public <T extends TriggeringPolicy> T getTriggeringPolicy()
T
- TriggeringPolicy typepublic RolloverStrategy getRolloverStrategy()
public void updateData(Object data)
updateData
in class AbstractManager
data
- The data to update.Copyright © 1999-2021 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.