java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<E>
ch.qos.logback.core.OutputStreamAppender<E>
ch.qos.logback.core.FileAppender<E>
- All Implemented Interfaces:
Appender<E>,ContextAware,FilterAttachable<E>,LifeCycle
- Direct Known Subclasses:
RollingFileAppender
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
FieldsModifier and TypeFieldDescriptionprotected booleanAppend to or truncate the file? The default value for this variable istrue, meaning that by default aFileAppenderwill append to an existing file and not truncate it.protected static Stringstatic final longprotected StringThe name of the active log file.Fields inherited from class ch.qos.logback.core.OutputStreamAppender
encoder, streamWriteLockFields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
name, startedFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddErrorForCollision(String optionName, String optionValue, String appenderName) protected booleangetFile()Returns the value of the File property.booleanisAppend()Returns the value of the Append property.booleanvoidSets and opens the file where the log output will go.final StringThis method is used by derived classes to obtain the raw file property.voidsetAppend(boolean append) voidsetBufferSize(FileSize bufferSize) voidThe File property takes a string value which should be the name of the file to append to.voidsetPrudent(boolean prudent) When prudent is set to true, file appenders from multiple JVMs can safely write to the same file.voidstart()If the value of File is notnull, thenopenFile(java.lang.String)is called with the values of File and Append properties.voidstop()Stop this appender instance.protected voidMethods inherited from class ch.qos.logback.core.OutputStreamAppender
append, closeOutputStream, getEncoder, getOutputStream, isImmediateFlush, setEncoder, setImmediateFlush, setLayout, setOutputStream, subAppend, updateByteCount, writeByteArrayToOutputStreamWithPossibleFlushMethods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toStringMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Field Details
-
DEFAULT_BUFFER_SIZE
- See Also:
-
COLLISION_WITH_EARLIER_APPENDER_URL
-
append
Append to or truncate the file? The default value for this variable istrue, meaning that by default aFileAppenderwill append to an existing file and not truncate it. -
fileName
-
-
Constructor Details
-
FileAppender
public FileAppender()
-
-
Method Details
-
setFile
-
isAppend
Returns the value of the Append property. -
rawFileProperty
This method is used by derived classes to obtain the raw file property. Regular users should not be calling this method.- Returns:
- the value of the file property
-
getFile
-
start
If the value of File is notnull, thenopenFile(java.lang.String)is called with the values of File and Append properties.- Specified by:
startin interfaceLifeCycle- Overrides:
startin classOutputStreamAppender<E>
-
stop
Description copied from class:OutputStreamAppenderStop this appender instance. The underlying stream or writer is also closed.Stopped appenders cannot be reused.
- Specified by:
stopin interfaceLifeCycle- Overrides:
stopin classOutputStreamAppender<E>
-
checkForFileCollisionInPreviousFileAppenders
-
addErrorForCollision
-
openFile
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- The path to the log file.- Throws:
IOException
-
isPrudent
- Returns:
- true if in prudent mode
- See Also:
-
setPrudent
When prudent is set to true, file appenders from multiple JVMs can safely write to the same file.- Parameters:
prudent-
-
setAppend
-
setBufferSize
-
writeOut
- Overrides:
writeOutin classOutputStreamAppender<E>- Throws:
IOException
-