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 time,
TriggeringPolicy triggeringPolicy,
RolloverStrategy rolloverStrategy,
String advertiseURI,
Layout<? extends Serializable> layout,
boolean writeHeader,
ByteBuffer buffer) |
protected |
RollingFileManager(String fileName,
String pattern,
OutputStream os,
boolean append,
long size,
long time,
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 time,
TriggeringPolicy triggeringPolicy,
RolloverStrategy rolloverStrategy,
String advertiseURI,
Layout<? extends Serializable> layout,
int bufferSize,
boolean writeHeader)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
checkRollover(LogEvent event)
Determines if a rollover should occur.
|
protected void |
createFileAfterRollover() |
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,
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 |
isRenameEmptyFiles() |
boolean |
releaseSub(long timeout,
TimeUnit timeUnit)
Default hook to write footer during close.
|
void |
rollover() |
void |
setRenameEmptyFiles(boolean renameEmptyFiles) |
void |
setRolloverStrategy(RolloverStrategy rolloverStrategy) |
void |
setTriggeringPolicy(TriggeringPolicy triggeringPolicy) |
void |
updateData(Object data) |
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, getBufferSize, getContentFormat, getFileManager, isAppend, isCreateOnDemand, isLocking
closeOutputStream, drain, flush, flushBuffer, flushDestination, getByteBuffer, getManager, getOutputStream, hasOutputStream, isOpen, setOutputStream, skipFooter, write, write, write, writeFooter
close, getCount, getLoggerContext, getName, hasManager, log, logDebug, logError, logWarn, release, stop
@Deprecated protected RollingFileManager(String fileName, String pattern, OutputStream os, boolean append, long size, long time, 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 time, 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 time, TriggeringPolicy triggeringPolicy, RolloverStrategy rolloverStrategy, String advertiseURI, Layout<? extends Serializable> layout, 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, 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.)configuration
- The configuration.public String getFileName()
getFileName
in class FileManager
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 <T extends TriggeringPolicy> T getTriggeringPolicy()
T
- TriggeringPolicy typepublic RolloverStrategy getRolloverStrategy()
public void updateData(Object data)
updateData
in class AbstractManager
Copyright © 1999-2017. 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.