Class MemoryMappedFileAppender
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<MemoryMappedFileManager>
org.apache.logging.log4j.core.appender.MemoryMappedFileAppender
- All Implemented Interfaces:
Appender, Filterable, LocationAware, LifeCycle, LifeCycle2
@Plugin(name="MemoryMappedFile",
category="Core",
elementType="appender",
printObject=true)
public final class MemoryMappedFileAppender
extends AbstractOutputStreamAppender<MemoryMappedFileManager>
Memory Mapped File Appender.
- Since:
- 2.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds RandomAccessFileAppender instances.Nested classes/interfaces inherited from interface LifeCycle
LifeCycle.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Objectprivate final Advertiserprivate static final intprivate final Stringprivate static final intprivate static final intFields inherited from class AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGERFields inherited from interface Appender
ELEMENT_TYPE, EMPTY_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMemoryMappedFileAppender(String name, Layout<? extends Serializable> layout, Filter filter, MemoryMappedFileManager manager, String filename, boolean ignoreExceptions, boolean immediateFlush, Advertiser advertiser, Property[] properties) -
Method Summary
Modifier and TypeMethodDescriptionstatic <B extends MemoryMappedFileAppender.Builder<B>>
MemoryMappedFileAppendercreateAppender(String fileName, String append, String name, String immediateFlush, String regionLengthStr, String ignore, Layout<? extends Serializable> layout, Filter filter, String advertise, String advertiseURI, Configuration config) Deprecated.private static intdetermineValidRegionLength(String name, int regionLength) Converts the specified region length to a valid value.Returns the file name this appender is associated with.intReturns the length of the memory mapped region.static <B extends MemoryMappedFileAppender.Builder<B>>
BbooleanCleanup the Filter.Methods inherited from class AbstractOutputStreamAppender
append, directEncodeEvent, getImmediateFlush, getManager, start, stop, writeByteArrayToManagerMethods inherited from class AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toStringMethods inherited from class AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilterMethods inherited from class AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
-
Field Details
-
BIT_POSITION_1GB
private static final int BIT_POSITION_1GB- See Also:
-
MAX_REGION_LENGTH
private static final int MAX_REGION_LENGTH- See Also:
-
MIN_REGION_LENGTH
private static final int MIN_REGION_LENGTH- See Also:
-
fileName
-
advertisement
-
advertiser
-
-
Constructor Details
-
MemoryMappedFileAppender
private MemoryMappedFileAppender(String name, Layout<? extends Serializable> layout, Filter filter, MemoryMappedFileManager manager, String filename, boolean ignoreExceptions, boolean immediateFlush, Advertiser advertiser, Property[] properties)
-
-
Method Details
-
stop
Description copied from class:AbstractFilterableCleanup the Filter.- Specified by:
stopin interfaceLifeCycle2- Overrides:
stopin classAbstractOutputStreamAppender<MemoryMappedFileManager>- 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.
-
getFileName
Returns the file name this appender is associated with.- Returns:
- The File name.
-
getRegionLength
public int getRegionLength()Returns the length of the memory mapped region.- Returns:
- the length of the memory mapped region
-
createAppender
@Deprecated public static <B extends MemoryMappedFileAppender.Builder<B>> MemoryMappedFileAppender createAppender(String fileName, String append, String name, String immediateFlush, String regionLengthStr, String ignore, Layout<? extends Serializable> layout, Filter filter, String advertise, String advertiseURI, Configuration config) Deprecated.UsenewBuilder().Create a Memory Mapped File Appender.- Parameters:
fileName- The name and path of the file.append- "True" if the file should be appended to, "false" if it should be overwritten. The default is "true".name- The name of the Appender.immediateFlush- "true" if the contents should be flushed on every write, "false" otherwise. The default is "false".regionLengthStr- The buffer size, defaults to 33554432.ignore- If"true"(default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.layout- The layout to use to format the event. If no layout is provided the default PatternLayout will be used.filter- The filter, if any, to use.advertise- "true" if the appender configuration should be advertised, "false" otherwise.advertiseURI- The advertised URI which can be used to retrieve the file contents.config- The Configuration.- Returns:
- The FileAppender.
-
newBuilder
-
determineValidRegionLength
Converts the specified region length to a valid value.
-
newBuilder().