public class FileTargetFactory extends AbstractTargetFactory
<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:
%7.7{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\\n%{throwable}
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.
| Modifier and Type | Field and Description |
|---|---|
private static long |
DAY |
private static long |
HOUR |
private static long |
KILOBYTE |
private static long |
MEGABYTE |
private static long |
MINUTE |
private static long |
SECOND |
m_configuration, m_context| Constructor and Description |
|---|
FileTargetFactory() |
| Modifier and Type | Method and Description |
|---|---|
org.apache.log.LogTarget |
createTarget(org.apache.avalon.framework.configuration.Configuration configuration)
Create a LogTarget based on a Configuration
|
protected org.apache.log.LogTarget |
createTarget(java.io.File file,
org.apache.avalon.framework.configuration.Configuration configuration) |
protected java.lang.String |
getFilename(java.lang.String rawFilename)
Process the file name.
|
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) |
protected org.apache.log.output.io.rotate.RotateStrategy |
getRotateStrategy(org.apache.avalon.framework.configuration.Configuration conf) |
configure, contextualizeprivate static final long SECOND
private static final long MINUTE
private static final long HOUR
private static final long DAY
private static final long KILOBYTE
private static final long MEGABYTE
public final org.apache.log.LogTarget createTarget(org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.configuration.ConfigurationExceptionprotected org.apache.log.LogTarget createTarget(java.io.File file,
org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.configuration.ConfigurationExceptionprotected org.apache.log.output.io.rotate.RotateStrategy getRotateStrategy(org.apache.avalon.framework.configuration.Configuration conf)
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)
protected final java.lang.String getFilename(java.lang.String rawFilename)
throws org.apache.avalon.framework.configuration.ConfigurationException
rawFilename - The filename with substitutable placeholdersorg.apache.avalon.framework.configuration.ConfigurationException - if substitutable values are not in the
Context object.