Class RollingRandomAccessFileAppender
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilterable
org.apache.logging.log4j.core.appender.AbstractAppender
org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender<RollingRandomAccessFileManager>
org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
- All Implemented Interfaces:
Appender
,Filterable
,LocationAware
,LifeCycle
,LifeCycle2
@Plugin(name="RollingRandomAccessFile",
category="Core",
elementType="appender",
printObject=true)
public final class RollingRandomAccessFileAppender
extends AbstractOutputStreamAppender<RollingRandomAccessFileManager>
An appender that writes to random access files and can roll over at
intervals.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Fields inherited from interface org.apache.logging.log4j.core.Appender
ELEMENT_TYPE, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Write the log entry rolling over the file when required.static <B extends RollingRandomAccessFileAppender.Builder<B>>
RollingRandomAccessFileAppendercreateAppender
(String fileName, String filePattern, String append, String name, String immediateFlush, String bufferSizeStr, TriggeringPolicy policy, RolloverStrategy strategy, Layout<? extends Serializable> layout, Filter filter, String ignoreExceptions, String advertise, String advertiseURI, Configuration configuration) Deprecated.int
Returns the size of the file manager's buffer.Returns the File name for the Appender.Returns the file pattern used when rolling over.static <B extends RollingRandomAccessFileAppender.Builder<B>>
Bboolean
Cleanup the Filter.Methods inherited from class org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
directEncodeEvent, getImmediateFlush, getManager, start, stop, writeByteArrayToManager
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toString
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
-
Method Details
-
stop
Description copied from class:AbstractFilterable
Cleanup the Filter.- Specified by:
stop
in interfaceLifeCycle2
- Overrides:
stop
in classAbstractOutputStreamAppender<RollingRandomAccessFileManager>
- Parameters:
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argument- Returns:
- true if the receiver was stopped cleanly and normally, false otherwise.
-
append
Write the log entry rolling over the file when required.- Specified by:
append
in interfaceAppender
- Overrides:
append
in classAbstractOutputStreamAppender<RollingRandomAccessFileManager>
- Parameters:
event
- The LogEvent.
-
getFileName
Returns the File name for the Appender.- Returns:
- The file name.
-
getFilePattern
Returns the file pattern used when rolling over.- Returns:
- The file pattern.
-
getBufferSize
public int getBufferSize()Returns the size of the file manager's buffer.- Returns:
- the buffer size
-
createAppender
@Deprecated public static <B extends RollingRandomAccessFileAppender.Builder<B>> RollingRandomAccessFileAppender createAppender(String fileName, String filePattern, String append, String name, String immediateFlush, String bufferSizeStr, TriggeringPolicy policy, RolloverStrategy strategy, Layout<? extends Serializable> layout, Filter filter, String ignoreExceptions, String advertise, String advertiseURI, Configuration configuration) Deprecated.UsenewBuilder()
.Create a RollingRandomAccessFileAppender.- Parameters:
fileName
- The name of the file that is actively written to. (required).filePattern
- The pattern of the file name to use on rollover. (required).append
- If true, events are appended to the file. If false, the file is overwritten when opened. Defaults to "true"name
- The name of the Appender (required).immediateFlush
- When true, events are immediately flushed. Defaults to "true".bufferSizeStr
- The buffer size, defaults to 262144.policy
- The triggering policy. (required).strategy
- The rollover strategy. Defaults to DefaultRolloverStrategy.layout
- The layout to use (defaults to the default PatternLayout).filter
- The Filter or null.ignoreExceptions
- If"true"
(default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.advertise
- "true" if the appender configuration should be advertised, "false" otherwise.advertiseURI
- The advertised URI which can be used to retrieve the file contents.configuration
- The Configuration.- Returns:
- A RollingRandomAccessFileAppender.
-
newBuilder
@PluginBuilderFactory public static <B extends RollingRandomAccessFileAppender.Builder<B>> B newBuilder()
-
newBuilder()
.