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 Classes Modifier and Type Class Description static class
MemoryMappedFileAppender.Builder<B extends MemoryMappedFileAppender.Builder<B>>
Builds RandomAccessFileAppender instances.-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
advertisement
private Advertiser
advertiser
private static int
BIT_POSITION_1GB
private java.lang.String
fileName
private static int
MAX_REGION_LENGTH
private static int
MIN_REGION_LENGTH
-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description private
MemoryMappedFileAppender(java.lang.String name, Layout<? extends java.io.Serializable> layout, Filter filter, MemoryMappedFileManager manager, java.lang.String filename, boolean ignoreExceptions, boolean immediateFlush, Advertiser advertiser, Property[] properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <B extends MemoryMappedFileAppender.Builder<B>>
MemoryMappedFileAppendercreateAppender(java.lang.String fileName, java.lang.String append, java.lang.String name, java.lang.String immediateFlush, java.lang.String regionLengthStr, java.lang.String ignore, Layout<? extends java.io.Serializable> layout, Filter filter, java.lang.String advertise, java.lang.String advertiseURI, Configuration config)
Deprecated.UsenewBuilder()
.private static int
determineValidRegionLength(java.lang.String name, int regionLength)
Converts the specified region length to a valid value.java.lang.String
getFileName()
Returns the file name this appender is associated with.int
getRegionLength()
Returns the length of the memory mapped region.static <B extends MemoryMappedFileAppender.Builder<B>>
BnewBuilder()
boolean
stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
Cleanup the Filter.-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
append, 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
-
-
-
-
Field Detail
-
BIT_POSITION_1GB
private static final int BIT_POSITION_1GB
- See Also:
- Constant Field Values
-
MAX_REGION_LENGTH
private static final int MAX_REGION_LENGTH
- See Also:
- Constant Field Values
-
MIN_REGION_LENGTH
private static final int MIN_REGION_LENGTH
- See Also:
- Constant Field Values
-
fileName
private final java.lang.String fileName
-
advertisement
private java.lang.Object advertisement
-
advertiser
private final Advertiser advertiser
-
-
Constructor Detail
-
MemoryMappedFileAppender
private MemoryMappedFileAppender(java.lang.String name, Layout<? extends java.io.Serializable> layout, Filter filter, MemoryMappedFileManager manager, java.lang.String filename, boolean ignoreExceptions, boolean immediateFlush, Advertiser advertiser, Property[] properties)
-
-
Method Detail
-
stop
public boolean stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
Description copied from class:AbstractFilterable
Cleanup the Filter.- Specified by:
stop
in interfaceLifeCycle2
- Overrides:
stop
in 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
public java.lang.String 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(java.lang.String fileName, java.lang.String append, java.lang.String name, java.lang.String immediateFlush, java.lang.String regionLengthStr, java.lang.String ignore, Layout<? extends java.io.Serializable> layout, Filter filter, java.lang.String advertise, java.lang.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
@PluginBuilderFactory public static <B extends MemoryMappedFileAppender.Builder<B>> B newBuilder()
-
determineValidRegionLength
private static int determineValidRegionLength(java.lang.String name, int regionLength)
Converts the specified region length to a valid value.
-
-