public class FileManager extends OutputStreamManager
| Modifier and Type | Class and Description |
|---|---|
private static class |
FileManager.FactoryData
Factory Data.
|
private static class |
FileManager.FileManagerFactory
Factory to create a FileManager.
|
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
advertiseURI |
private int |
bufferSize |
private boolean |
createOnDemand |
private static FileManager.FileManagerFactory |
FACTORY |
private boolean |
isAppend |
private boolean |
isLocking |
byteBuffer, layoutcount, LOGGER| Modifier | Constructor and Description |
|---|---|
protected |
FileManager(LoggerContext loggerContext,
java.lang.String fileName,
java.io.OutputStream os,
boolean append,
boolean locking,
boolean createOnDemand,
java.lang.String advertiseURI,
Layout<? extends java.io.Serializable> layout,
boolean writeHeader,
java.nio.ByteBuffer buffer) |
protected |
FileManager(java.lang.String fileName,
java.io.OutputStream os,
boolean append,
boolean locking,
java.lang.String advertiseURI,
Layout<? extends java.io.Serializable> layout,
boolean writeHeader,
java.nio.ByteBuffer buffer)
Deprecated.
|
protected |
FileManager(java.lang.String fileName,
java.io.OutputStream os,
boolean append,
boolean locking,
java.lang.String advertiseURI,
Layout<? extends java.io.Serializable> layout,
int bufferSize,
boolean writeHeader)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.io.OutputStream |
createOutputStream() |
int |
getBufferSize()
Returns the buffer size to use if the appender was configured with BufferedIO=true, otherwise returns a negative
number.
|
java.util.Map<java.lang.String,java.lang.String> |
getContentFormat()
FileManager's content format is specified by:
Key: "fileURI" Value: provided "advertiseURI" param. |
static FileManager |
getFileManager(java.lang.String fileName,
boolean append,
boolean locking,
boolean bufferedIo,
boolean createOnDemand,
java.lang.String advertiseUri,
Layout<? extends java.io.Serializable> layout,
int bufferSize,
Configuration configuration)
Returns the FileManager.
|
java.lang.String |
getFileName()
Returns the name of the File being managed.
|
boolean |
isAppend()
Returns the append status.
|
boolean |
isCreateOnDemand()
Returns the lazy-create.
|
boolean |
isLocking()
Returns the lock status.
|
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. |
closeOutputStream, drain, flush, flushBuffer, flushDestination, getByteBuffer, getManager, getOutputStream, hasOutputStream, isOpen, releaseSub, setOutputStream, skipFooter, write, write, write, writeFooterclose, getCount, getLoggerContext, getName, hasManager, log, logDebug, logError, logWarn, release, stop, updateDataprivate static final FileManager.FileManagerFactory FACTORY
private final boolean isAppend
private final boolean createOnDemand
private final boolean isLocking
private final java.lang.String advertiseURI
private final int bufferSize
@Deprecated
protected FileManager(java.lang.String fileName,
java.io.OutputStream os,
boolean append,
boolean locking,
java.lang.String advertiseURI,
Layout<? extends java.io.Serializable> layout,
int bufferSize,
boolean writeHeader)
@Deprecated
protected FileManager(java.lang.String fileName,
java.io.OutputStream os,
boolean append,
boolean locking,
java.lang.String advertiseURI,
Layout<? extends java.io.Serializable> layout,
boolean writeHeader,
java.nio.ByteBuffer buffer)
protected FileManager(LoggerContext loggerContext, java.lang.String fileName, java.io.OutputStream os, boolean append, boolean locking, boolean createOnDemand, java.lang.String advertiseURI, Layout<? extends java.io.Serializable> layout, boolean writeHeader, java.nio.ByteBuffer buffer)
public static FileManager getFileManager(java.lang.String fileName, boolean append, boolean locking, boolean bufferedIo, boolean createOnDemand, java.lang.String advertiseUri, Layout<? extends java.io.Serializable> layout, int bufferSize, Configuration configuration)
fileName - The name of the file to manage.append - true if the file should be appended to, false if it should be overwritten.locking - true if the file should be locked while writing, false otherwise.bufferedIo - true if the contents should be buffered as they are written.createOnDemand - true if you want to lazy-create the file (a.k.a. on-demand.)advertiseUri - the URI to use when advertising the filelayout - The layoutbufferSize - buffer size for buffered IOconfiguration - The configuration.protected java.io.OutputStream createOutputStream()
throws java.io.FileNotFoundException
createOutputStream in class OutputStreamManagerjava.io.FileNotFoundExceptionprotected void write(byte[] bytes,
int offset,
int length,
boolean immediateFlush)
OutputStreamManagerwrite in class OutputStreamManagerbytes - 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)
OutputStreamManager.writeToDestination(byte[], int, int) to add support for file locking.writeToDestination in class OutputStreamManagerbytes - the array containing dataoffset - from where to writelength - how many bytes to writepublic java.lang.String getFileName()
public boolean isAppend()
public boolean isCreateOnDemand()
public boolean isLocking()
public int getBufferSize()
public java.util.Map<java.lang.String,java.lang.String> getContentFormat()
Key: "fileURI" Value: provided "advertiseURI" param.getContentFormat in class AbstractManager