org.apache.avalon.logging.logkit.factory
Class FileTargetFactory
java.lang.Object
org.apache.avalon.logging.logkit.factory.FileTargetFactory
- All Implemented Interfaces:
- LogTargetFactory
- public class FileTargetFactory
- extends Object
- implements LogTargetFactory
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="avalon|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>
</rotation>
</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.
The initial rotation
can be set to -1 in which case the system will first create the maximum
number of file rotations by selecting the next available rotation and thereafter
will overwrite the oldest log file.
- <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.
- <date>
-
Rotation occur when string formatted date changed. Specify date formatting pattern.
- <interval>
-
Interval at which a rotation should occur. The interval should be given in the
format ddd:hh:mm:ss.
- Version:
- CVS $Revision: 1.3 $ $Date: 2004/03/08 11:32:01 $
- Author:
- Avalon Development Team
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileTargetFactory
public FileTargetFactory(File basedir,
FormatterFactory formatter)
createTarget
public final LogTarget createTarget(Configuration configuration)
throws LogTargetException
- Create a LogTarget based on a Configuration
- Specified by:
createTarget
in interface LogTargetFactory
- Throws:
LogTargetException
getFileStrategy
protected FileStrategy getFileStrategy(Configuration conf,
File file)
Copyright © The Apache Software Foundation. All Rights Reserved.