|
Log4j 1.1b7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.log4j.AppenderSkeleton | +--org.apache.log4j.WriterAppender | +--org.apache.log4j.FileAppender
FileAppender appends log events to a file.
Support for java.io.Writer and console appending has been
deprecated and will be removed in the near future. You are
stongly encouraged to use the replacement solutions: WriterAppender
and ConsoleAppender
.
Field Summary | |
static String |
APPEND_OPTION
Deprecated. We now use JavaBeans introspection to configure components. Options strings are no longer needed. |
static String |
FILE_OPTION
Deprecated. We now use JavaBeans introspection to configure components. Options strings are no longer needed. |
protected boolean |
fileAppend
Append to or truncate the file? |
protected String |
fileName
The name of the log file. |
protected boolean |
qwIsOurs
Deprecated. FileAppender will not support streams passed by the user in the future. |
Fields inherited from class org.apache.log4j.WriterAppender |
IMMEDIATE_FLUSH_OPTION, immediateFlush, qw |
Fields inherited from class org.apache.log4j.AppenderSkeleton |
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION |
Constructor Summary | |
FileAppender()
The default constructor does not do anything. |
|
FileAppender(Layout layout,
OutputStream os)
Deprecated. The functionality of this constructor form has been replaced by the WriterAppender . This constructor
will be removed in the near term. |
|
FileAppender(Layout layout,
String filename)
Instantiate a FileAppender and open the file designated by filename . |
|
FileAppender(Layout layout,
String filename,
boolean append)
Instantiate a FileAppender and open the file designated by filename . |
|
FileAppender(Layout layout,
Writer writer)
Deprecated. The functionality of constructor form has been replaced by the WriterAppender . This constructor will be
removed in the near term. |
Method Summary | |
void |
activateOptions()
If the value of FILE_OPTION is not null , then setFile(java.lang.String) is called with the values of FILE_OPTION and
APPEND_OPTION . |
protected void |
closeFile()
Closes the previously opened file. |
boolean |
getAppend()
Returns the value of the Append option. |
String |
getFile()
Returns the value of the File option. |
String[] |
getOptionStrings()
Deprecated. We now use JavaBeans introspection to configure components. Options strings are no longer needed. |
protected void |
reset()
Close any previously opened file and call the parent's reset . |
void |
setAppend(boolean flag)
|
void |
setFile(String file)
The File option takes a string value which should be the name of the file to append to. |
void |
setFile(String fileName,
boolean append)
Sets and opens the file where the log output will go. |
void |
setOption(String key,
String value)
Set option to value .
|
protected void |
setQWForFiles(Writer writer)
Sets the quiet writer being used. |
Methods inherited from class org.apache.log4j.WriterAppender |
append, checkEntryConditions, close, closeWriter, getImmediateFlush, requiresLayout, setErrorHandler, setImmediateFlush, setWriter, subAppend, writeFooter, writeHeader |
Methods inherited from class org.apache.log4j.AppenderSkeleton |
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setLayout, setName, setThreshold |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String FILE_OPTION
Note that all option keys are case sensitive.
public static final String APPEND_OPTION
Note that all option keys are case sensitive.
protected boolean fileAppend
true
, meaning that by default a
FileAppender
will append to an existing file and
not truncate it.
This option is meaningful only if the FileAppender opens the file.
protected String fileName
protected boolean qwIsOurs
Constructor Detail |
public FileAppender()
public FileAppender(Layout layout, OutputStream os)
WriterAppender
. This constructor
will be removed in the near term.
OutputStreamWriter
initialized with os
as its OutputStream
.public FileAppender(Layout layout, Writer writer)
WriterAppender
. This constructor will be
removed in the near term.
writer
.
The writer
must have been opened by the user.
public FileAppender(Layout layout, String filename, boolean append) throws IOException
filename
. The opened filename will become the ouput
destination for this appender.
If the append
parameter is true, the file will be
appended to. Otherwise, the file designated by
filename
will be truncated before being opened.
public FileAppender(Layout layout, String filename) throws IOException
filename
. The opened filename will become the output
destination for this appender.
The file will be appended to.
Method Detail |
public void setFile(String file)
Note that the "System.out" or "System.err"
options are deprecated. Use ConsoleAppender
instead.
If the option is set to "System.out" or "System.err" the output will go to the corresponding stream. Otherwise, if the option is set to the name of a file, then the file will be opened and output will go there.
Note: Actual opening of the file is made when activateOptions()
is called, not when the options are set.
public boolean getAppend()
public String getFile()
public String[] getOptionStrings()
FILE_OPTION
, APPEND_OPTION
} in addition
to the options of its super class WriterAppender
.getOptionStrings
in class WriterAppender
public void setAppend(boolean flag)
true
by default. If true, then File
will be opened in append mode by setFile
(see
above). Otherwise, setFile
will open
File
in truncate mode.
Note: Actual opening of the file is made when activateOptions()
is called, not when the options are set.
public void activateOptions()
FILE_OPTION
is not null
, then setFile(java.lang.String)
is called with the values of FILE_OPTION
and
APPEND_OPTION
.activateOptions
in class WriterAppender
protected void closeFile()
public void setFile(String fileName, boolean append) 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.
fileName
- The path to the log file.append
- If true will append to fileName. Otherwise will
truncate fileName.public void setOption(String key, String value)
setOption
method.
OptionHandler
option
to value
.
The handling of each option depends on the OptionHandler
instance. Some options may become active immediately whereas
other may be activated only when OptionHandler.activateOptions()
is
called.
setOption
in class WriterAppender
protected void setQWForFiles(Writer writer)
RollingFileAppender
.protected void reset()
reset
.reset
in class WriterAppender
|
Log4j 1.1b7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |