|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.logging.Handler
org.x4juli.global.components.AbstractHandler
org.x4juli.handlers.WriterHandler
org.x4juli.handlers.FileHandler
FileHandler publishes log records to a file. Please refer also to parent classes for further configuration information.
| Attribute | Description | Required |
|---|---|---|
| .append | Append to existing files. Allowed values "true" or "false". | No. Default false. |
| .filename | Full or relative Path and Name of the file. | YES. Default value of "user.home"/juli.log |
| .bufferedIO | To buffer write access to the file. Allowed values "true" or "false". | No. Default false. |
| .buffersize | Size of the IO buffer. Allowed value is an integer. | No. Default 8kb. |
FileHandler can be configured programattically or using
configuration by file. Do not use the default constructor in
programattically use.
Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Ceki Gülcü. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.
| Field Summary | |
protected boolean |
bufferedIO
Do we do bufferedIO? |
protected int |
bufferSize
The size of the IO buffer. |
protected static int |
DEFAULT_BUFFER_SIZE
Default Size of an Buffered IO. |
protected boolean |
fileAppend
Append to or truncate the file? |
protected java.lang.String |
fileName
The name of the log file. |
| Fields inherited from class org.x4juli.handlers.WriterHandler |
immediateFlush, writer |
| Fields inherited from class org.x4juli.global.components.AbstractHandler |
active, closed, extFormatter, headFilter, manager, name, repository, tailFilter |
| Fields inherited from class java.util.logging.Handler |
|
| Constructor Summary | |
FileHandler()
Default Constructor instantiation used for configuration by file. |
|
FileHandler(java.lang.String handlerName)
Utility Constructor. |
|
| Method Summary | |
void |
activateOptions()
Activate the options that were previously set with calls to option setters.
This allows to defer activiation of the options until all options have
been set. This is required for components which have related options that
remain ambigous until all are set.
|
void |
configure()
Configure all properties of the object. Subclasses should call super.configure() to ensure proper configuration. |
boolean |
getAppend()
Returns the value of the Append option. |
boolean |
getBufferedIO()
Get the value of the BufferedIO option. |
int |
getBufferSize()
Get the size of the IO buffer. |
java.lang.String |
getFile()
Returns the value of the File option. |
java.lang.String |
getFullQualifiedClassName()
Determine performant the FullQualifiedClassName. Subclasses should overwrite this method. Dynamic determination is not recommended. |
void |
setAppend(boolean flag)
The Append option takes a boolean value. |
void |
setBufferedIO(boolean bufferedIO)
The BufferedIO option takes a boolean value. |
void |
setBufferSize(int bufferSize)
Set the size of the IO buffer. |
void |
setFile(java.lang.String file)
The File property takes a string value which should be the name of the file to append to. |
void |
setFile(java.lang.String filename,
boolean append,
boolean bufferedIO,
int bufferSize)
Sets and opens the file where the log output will go. |
| Methods inherited from class org.x4juli.handlers.WriterHandler |
appendLogRecord, checkEntryConditions, close, closeWriter, createWriter, flush, getImmediateFlush, setImmediateFlush, setWriter, subAppend, writeFooter, writeHeader |
| Methods inherited from class org.x4juli.global.components.AbstractHandler |
addFilter, clearFilters, finalize, getFilter, getFormatter, getLogger, getLoggerRepository, getMessageProperties, getName, getNonFloodingLogger, getProperty, getProperty, getProperty, isActive, isClosed, isLoggable, isLoggable, publish, publish, resetErrorCount, setFilter, setFormatter, setName, setObjectStore, toString |
| Methods inherited from class java.util.logging.Handler |
getEncoding, getErrorManager, getLevel, reportError, setEncoding, setErrorManager, setLevel |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.x4juli.global.spi.ExtendedHandler |
getEncoding, getErrorManager, getLevel, setEncoding, setErrorManager, setLevel |
| Field Detail |
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 java.lang.String fileName
protected boolean bufferedIO
protected static final int DEFAULT_BUFFER_SIZE
protected int bufferSize
| Constructor Detail |
public FileHandler()
public FileHandler(java.lang.String handlerName)
handlerName - of the current instance.| Method Detail |
public java.lang.String getFullQualifiedClassName()
getFullQualifiedClassName in interface ExtendedHandlergetFullQualifiedClassName in class WriterHandlerpublic void setFile(java.lang.String file)
Note: Actual opening of the file is made when activateOptions() is
called, not when the options are set.
file - name of the file to use.public boolean getAppend()
public java.lang.String getFile()
public void activateOptions()
This allows to defer activiation of the options until all options have
been set. This is required for components which have related options that
remain ambigous until all are set.
Subclasses have not set active to true, but call super as
last statement!
activateOptions in interface OptionHandleractivateOptions in class WriterHandlerpublic void configure()
configure in class WriterHandlerpublic boolean getBufferedIO()
BufferedIO will significatnly increase performance on heavily loaded systems.
public int getBufferSize()
public void setAppend(boolean flag)
true by default. If true, then File will be
opened in append mode by setFile(String) (see above). Otherwise,
setFile(String) will open File in truncate mode.
Note: Actual opening of the file is made when activateOptions() is
called, not when the options are set.
flag - to append or notpublic void setBufferedIO(boolean bufferedIO)
false by default. If true, then File will
be opened and the resulting Writer wrapped around a
BufferedWriter.
BufferedIO will significatnly increase performance on heavily loaded
systems.
bufferedIO - to buffer IO or notpublic void setBufferSize(int bufferSize)
bufferSize - size of the buffer, used if buffered IO is true
public void setFile(java.lang.String filename,
boolean append,
boolean bufferedIO,
int bufferSize)
throws java.io.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 activateOptions.
filename - The path to the log file.append - If true will append to fileName. Otherwise will truncate
fileName.bufferedIO - to buffer IO or not.bufferSize - size of the buffer for IO.
java.io.IOException - if file does not exist and cannot be created.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||