Top Description Fields Constructors Methods
ch.qos.logback.core

public Class FileAppender<E>

extends OutputStreamAppender<E>
Class Inheritance
Known Direct Subclasses
ch.qos.logback.core.rolling.RollingFileAppender
Static Imports
ch.qos.logback.core.CoreConstants.CODES_URL, .CoreConstants.MORE_INFO_PREFIX

FileAppender appends log events to a file. For more information about this appender, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#FileAppender
Author
Ceki Gülcü

Field Summary

Modifier and TypeField and Description
protected boolean
append

Append to or truncate the file?

private FileSize
protected static String
public static final long
protected String
fileName

The name of the active log file.

private boolean
Inherited from ch.qos.logback.core.OutputStreamAppender:
encoderimmediateFlushstreamWriteLock

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
addErrorForCollision(String optionName, String optionValue, String appenderName)

protected boolean
public String
getFile()

Returns the value of the File property.

public boolean
isAppend()

Returns the value of the Append property.

public boolean

Returns:

true if in prudent mode
isPrudent
()

public void
openFile(String
The path to the log file.
file_name
)

Sets and opens the file where the log output will go.

public final String

Returns:

the value of the file property
rawFileProperty
()

This method is used by derived classes to obtain the raw file property.

private void
private void
safeWriteBytes(byte[] byteArray)

private void
safeWriteOut(E event)

public void
setAppend(boolean append)

public void
setBufferSize(FileSize bufferSize)

public void
setFile(String file)

The File property takes a string value which should be the name of the file to append to.

public void
setPrudent(boolean prudent)

When prudent is set to true, file appenders from multiple JVMs can safely write to the same file.

public void
start()

Overrides ch.qos.logback.core.OutputStreamAppender.start.

Implements ch.qos.logback.core.spi.LifeCycle.start.

If the value of File is not null, then openFile is called with the values of File and Append properties.
public void
protected void
Inherited from ch.qos.logback.core.OutputStreamAppender:
appendcloseOutputStreamencoderCloseencoderInitgetEncodergetOutputStreamisImmediateFlushsetEncodersetImmediateFlushsetLayoutsetOutputStreamsubAppendwriteByteArrayToOutputStreamWithPossibleFlush

Field Detail

appendback to summary
protected boolean append

Append to or truncate the file? The default value for this variable is true, meaning that by default a FileAppender will append to an existing file and not truncate it.

bufferSizeback to summary
private FileSize bufferSize
COLLISION_WITH_EARLIER_APPENDER_URLback to summary
protected static String COLLISION_WITH_EARLIER_APPENDER_URL
DEFAULT_BUFFER_SIZEback to summary
public static final long DEFAULT_BUFFER_SIZE
fileNameback to summary
protected String fileName

The name of the active log file.

prudentback to summary
private boolean prudent

Constructor Detail

FileAppenderback to summary
public FileAppender()

Method Detail

addErrorForCollisionback to summary
protected void addErrorForCollision(String optionName, String optionValue, String appenderName)
checkForFileCollisionInPreviousFileAppendersback to summary
protected boolean checkForFileCollisionInPreviousFileAppenders()
getFileback to summary
public String getFile()

Returns the value of the File property.

This method may be overridden by derived classes.

isAppendback to summary
public boolean isAppend()

Returns the value of the Append property.

isPrudentback to summary
public boolean isPrudent()
Returns:boolean

true if in prudent mode

See Also
setPrudent(boolean)
openFileback to summary
public void openFile(String file_name) throws IOException

Sets and opens the file where the log output will go. The specified file must be writable.

If there was already an opened file, then the previous file is closed first.

Do not use this method directly. To configure a FileAppender or one of its subclasses, set its properties one by one and then call start().

Parameters
file_name:String

The path to the log file.

rawFilePropertyback to summary
public final String rawFileProperty()

This method is used by derived classes to obtain the raw file property. Regular users should not be calling this method.

Returns:String

the value of the file property

releaseFileLockback to summary
private void releaseFileLock(FileLock fileLock)
safeWriteBytesback to summary
private void safeWriteBytes(byte[] byteArray)
safeWriteOutback to summary
private void safeWriteOut(E event)
setAppendback to summary
public void setAppend(boolean append)
setBufferSizeback to summary
public void setBufferSize(FileSize bufferSize)
setFileback to summary
public void setFile(String file)

The File property takes a string value which should be the name of the file to append to.

setPrudentback to summary
public void setPrudent(boolean prudent)

When prudent is set to true, file appenders from multiple JVMs can safely write to the same file.

startback to summary
public void start()

Overrides ch.qos.logback.core.OutputStreamAppender.start.

Implements ch.qos.logback.core.spi.LifeCycle.start.

If the value of File is not null, then openFile is called with the values of File and Append properties.

stopback to summary
public void stop()

Overrides ch.qos.logback.core.OutputStreamAppender.stop.

Implements ch.qos.logback.core.spi.LifeCycle.stop.

Doc from ch.qos.logback.core.OutputStreamAppender.stop.

Stop this appender instance. The underlying stream or writer is also closed.

Stopped appenders cannot be reused.

Annotations
@Override
writeOutback to summary
protected void writeOut(E event) throws IOException

Overrides ch.qos.logback.core.OutputStreamAppender.writeOut.

Annotations
@Override