org.apache.avalon.excalibur.logger.factory
Class FileTargetFactory
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLogEnabled
|
+--org.apache.avalon.excalibur.logger.factory.AbstractTargetFactory
|
+--org.apache.avalon.excalibur.logger.factory.FileTargetFactory
- All Implemented Interfaces:
- org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, LogTargetFactory
- public class FileTargetFactory
- extends AbstractTargetFactory
FileTargetFactory class.
This factory is able to create different FileLogTargets according to the following
configuration syntax:
<file id="foo">
<filename>${context-key}/real-name/...</filename>
<format type="raw|pattern|extended">pattern to be used if needed</format>
<append>true|false</append>
<rotation type="revolving" init="5" max="10">
or
<rotation type="unique" pattern="yyyy-MM-dd-hh-mm-ss" suffix=".log">
<or>
<size>10000000</size>
<time>24:00:00</time>
<time>12:00:00</time>
</or>
</rotate>
</file>
Some explanations about the Elements used in the configuration:
- <filename>
-
This denotes the name of the file to log to. It can be constructed
out of entries in the passed Context object as ${context-key}.
This element is required.
- <format>
-
The type attribute of the pattern element denotes the type of
Formatter to be used and according to it the pattern to use for.
This elements defaults to:
%7.7{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\\n%{throwable}
- <append>
-
-
If the log file should be deleted every time the logger is creates
(normally at the start of the applcation) or not and thus the log
entries will be appended. This elements defaults to false.
- <rotation>
-
This is an optional element.
The type attribute determines which FileStrategy to user
(revolving=RevolvingFileStrategy, unique=UniqueFileStrategy).
The required init and max attribute are used to determine the initial and
maximum rotation to use on a type="revolving" attribute.
The optional pattern and suffix attribute are used to form filenames on
a type="unique" attribute.
- <or>
- uses the OrRotateStrategy to combine the children
- <size>
-
The number of bytes if no suffix used or kilo bytes (1024) if suffixed with
'k' or mega bytes (1024k) if suffixed with 'm' when a file rotation should
occur. It doesn't make sense to specify more than one.
- <time>
-
The time as HH:MM:SS when a rotation should occur. If you like to rotate
a logfile more than once a day put an <or> element immediately after the
<rotation> element and specify the times (and one size, too) inside the
<or> element.
- Since:
- 4.0
- Version:
- CVS $Revision: 1.8 $ $Date: 2001/12/19 23:34:50 $
- Author:
- Giacomo Pati
Method Summary |
org.apache.log.LogTarget |
createTarget(org.apache.avalon.framework.configuration.Configuration configuration)
Create a LogTarget based on a Configuration |
protected java.lang.String |
getFilename(java.lang.String rawFilename)
Process the file name
This method scans the file name passed for occurrences of
${foo}. |
protected org.apache.log.output.io.rotate.FileStrategy |
getFileStrategy(org.apache.avalon.framework.configuration.Configuration conf,
java.io.File file)
|
protected org.apache.log.format.Formatter |
getFormatter(org.apache.avalon.framework.configuration.Configuration conf)
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileTargetFactory
public FileTargetFactory()
createTarget
public final org.apache.log.LogTarget createTarget(org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
- Create a LogTarget based on a Configuration
- Overrides:
createTarget
in class AbstractTargetFactory
getFileStrategy
protected org.apache.log.output.io.rotate.FileStrategy getFileStrategy(org.apache.avalon.framework.configuration.Configuration conf,
java.io.File file)
getFormatter
protected org.apache.log.format.Formatter getFormatter(org.apache.avalon.framework.configuration.Configuration conf)
getFilename
protected final java.lang.String getFilename(java.lang.String rawFilename)
throws org.apache.avalon.framework.configuration.ConfigurationException
- Process the file name
This method scans the file name passed for occurrences of
${foo}. Those strings get replaced by values from the Context object
indexted by the name (here foo).
- Parameters:
rawFilename
- The filename with substitutable placeholders- Returns:
- The processed file name
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException
- if substitutable values are not in the
Context object.
Copyright © 2001 Apache Jakarta Project. All Rights Reserved.