<property name="fileName"value="${logDir}/baz"/>
<slee-management>
<createfileappender appendername="foo"fileName="${logDir}/buz"/>
<createfileappender appendername="bar">
<propertyset>
<propertyref name="fileName"/>
</propertyset>
<component pluginname="filters">
<component pluginname="BurstFilter"properties="level=WARN,rate=3"/>
<component pluginname="ThresholdFilter"properties="level=trace"/>
</component>
<component pluginname="PatternLayout"properties="pattern=%d{yyyy-MM-dd HH:mm:ss.SSSZ} ${plainLevel} [%tracer{*.0.0.*}] <%threadName> %mdc %msg{nolookups}%n%throwable"/>
</createfileappender>
</slee-management>
Class CreateFileAppenderTask
- java.lang.Object
-
- com.opencloud.slee.mlet.ant.tasks.AbstractBaseTask
-
- com.opencloud.slee.mlet.ant.tasks.CreateGenericComponentTask
-
- com.opencloud.slee.mlet.ant.tasks.CreateAppenderTask
-
- com.opencloud.slee.mlet.ant.tasks.CreateOutputStreamAppenderTask
-
- com.opencloud.slee.mlet.ant.tasks.CreateFileAppenderTask
-
- All Implemented Interfaces:
SubTask
- Direct Known Subclasses:
CreateMemoryMappedFileAppenderTask
,CreateRandomAccessFileAppenderTask
,CreateRollingFileAppenderTask
public class CreateFileAppenderTask extends CreateOutputStreamAppenderTask
A Rhino management sub task for creating a log appender writing to a file opened in write-only mode.
Ant Parameters Attribute Type Description Required appendername
String
Name of the appender to create. This name must be unique.
Yes.
filename
String
Name of log file to write to.
Yes.
append
boolean
When true - the default, records will be appended to the end of the file. When set to false, the file will be cleared before new records are written.
No. If not specified, defaults to true.
bufferedio
boolean
When true - the default, records will be written to a buffer and the data will be written to disk when the buffer is full or, if immediateFlush is set, when the record is written. File locking cannot be used with bufferedIO. Performance tests have shown that using buffered I/O significantly improves performance, even if immediateFlush is enabled.
No. If not specified, defaults to true.
buffersize
int
When bufferedIO is true, this is the buffer size, the default is 8192 bytes.
No.
createondemand
boolean
The appender creates the file on-demand. The appender only creates the file when a log event passes all filters and is routed to this appender.
No. If not specified, defaults to false.
immediateflush
boolean
When set to true - the default, each write will be followed by a flush. This will guarantee the data is written to disk but could impact performance.
No. If not specified, defaults to true.
locking
boolean
When set to true, I/O operations will occur only while the file lock is held allowing FileAppenders in multiple JVMs and potentially multiple hosts to write to the same file simultaneously. This will significantly impact performance so should be used carefully. Furthermore, on many systems the file lock is "advisory" meaning that other applications can perform operations on the file without acquiring a lock.
No. If not specified, defaults to false.
ignoreexceptions
boolean
When set to true, causing exceptions encountered while appending events to be internally logged and then ignored. When set to false exceptions will be propagated to the caller, instead.
No. If not specified, defaults to true.
pattern
String
The pattern to use for logging output.
No. If not specified, the default is %m%n.
failonerror
boolean
Flag to control failure behaviour. If 'true', the sub task will throw a
BuildException
when an error is encountered. If 'false', the sub task will throw aNonFatalBuildException
instead of aBuildException
under specific circumstances. See below for conditions (if any) which will cause aNonFatalBuildException
.No. Default value is taken from the Rhino management parent task.
Nested elements Element
Description
Required
filter
A filter to select events that will be reported by this appender.
No.
layout
The layout to use to format log events. If no layout is supplied the default pattern layout of "%m%n" will be used.
No.
NonFatalBuildException throw conditions-
This task will throw a
NonFatalBuildException
if the appender cannot be created, eg. an appender with the same name already exists.
The snippet below creates two appenders: a simple file appender using the default pattern of
%m%n
(log message followed by a newline character); and a more complex configuration where the filename is taken from a property defined earlier in the Ant script and filters that accept all messages fromTrace
level up, but limiting WARN and lower severity messages to a maximum of 3 per second. The second appender uses a more complex pattern containing a date stamp, the log level, the tracer name, the thread name, the diagnostic context map, the log message and exception stack trace. The substitution propertylogDir
is defined in the Rhino logging configuration file. See https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout for the full pattern layout syntax.
-
-
Field Summary
-
Fields inherited from class com.opencloud.slee.mlet.ant.tasks.CreateAppenderTask
appenderName
-
Fields inherited from class com.opencloud.slee.mlet.ant.tasks.CreateGenericComponentTask
components, properties
-
Fields inherited from class com.opencloud.slee.mlet.ant.tasks.AbstractBaseTask
client, failOnError
-
-
Constructor Summary
Constructors Constructor Description CreateFileAppenderTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getPluginname()
void
setAppend(Boolean append)
void
setBufferedIO(Boolean bufferedIO)
void
setBufferSize(Integer bufferSize)
void
setCreateOnDemand(Boolean createOnDemand)
void
setFileName(String fileName)
void
setLocking(Boolean locking)
protected void
validateParameters()
-
Methods inherited from class com.opencloud.slee.mlet.ant.tasks.CreateOutputStreamAppenderTask
setImmediateFlush
-
Methods inherited from class com.opencloud.slee.mlet.ant.tasks.CreateAppenderTask
execute, setAppenderName, setIgnoreExceptions
-
Methods inherited from class com.opencloud.slee.mlet.ant.tasks.CreateGenericComponentTask
addComponent, addPropertyNotNull, addPropertySet, allTrue, buildGenericComponentData, expandPropertySets, getComponents, getPropertiesArray, setPluginname, setProperties, validateHasProperty
-
Methods inherited from class com.opencloud.slee.mlet.ant.tasks.AbstractBaseTask
getExceptionAndMessage, getFailOnError, getMessage, getOverrideFailOnError, getParent, getProject, log, run, setFailOnError
-
-
-
-
Method Detail
-
validateParameters
protected void validateParameters() throws org.apache.tools.ant.BuildException
- Overrides:
validateParameters
in classCreateAppenderTask
- Throws:
org.apache.tools.ant.BuildException
-
getPluginname
public String getPluginname()
- Overrides:
getPluginname
in classCreateGenericComponentTask
-
setFileName
public void setFileName(String fileName)
-
setAppend
public void setAppend(Boolean append)
-
setBufferedIO
public void setBufferedIO(Boolean bufferedIO)
-
setBufferSize
public void setBufferSize(Integer bufferSize)
-
setCreateOnDemand
public void setCreateOnDemand(Boolean createOnDemand)
-
setLocking
public void setLocking(Boolean locking)
-
-