Package com.codahale.metrics.log4j2
Class InstrumentedAppender
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.filter.AbstractFilterable
-
- org.apache.logging.log4j.core.appender.AbstractAppender
-
- com.codahale.metrics.log4j2.InstrumentedAppender
-
- All Implemented Interfaces:
org.apache.logging.log4j.core.Appender
,org.apache.logging.log4j.core.filter.Filterable
,org.apache.logging.log4j.core.LifeCycle
,org.apache.logging.log4j.core.LifeCycle2
@Plugin(name="MetricsAppender", category="Core", elementType="appender") public class InstrumentedAppender extends org.apache.logging.log4j.core.appender.AbstractAppender
A Log4J 2.xAppender
which has seven meters, one for each logging level and one for the total number of statements being logged. The meter names are the logging level names appended to the name of the appender.
-
-
Constructor Summary
Constructors Constructor Description InstrumentedAppender(MetricRegistry registry)
Create a new instrumented appender using the given registry.InstrumentedAppender(MetricRegistry registry, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions)
Create a new instrumented appender using the given registry.InstrumentedAppender(String registryName)
Create a new instrumented appender using the given registry name.InstrumentedAppender(String appenderName, MetricRegistry registry)
Create a new instrumented appender using the given appender name and registry.InstrumentedAppender(String registryName, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions)
Create a new instrumented appender using the given registry name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(org.apache.logging.log4j.core.LogEvent event)
static InstrumentedAppender
createAppender(String name, String registry)
void
start()
-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, setHandler, toSerializable, toString
-
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, stop, stop
-
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
-
-
-
-
Constructor Detail
-
InstrumentedAppender
public InstrumentedAppender(String registryName, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions)
Create a new instrumented appender using the given registry name.- Parameters:
registryName
- the name of the registry inSharedMetricRegistries
filter
- The Filter to associate with the Appender.layout
- The layout to use to format the event.ignoreExceptions
- If true, exceptions will be logged and suppressed. If false errors will be logged and then passed to the application.
-
InstrumentedAppender
public InstrumentedAppender(String registryName)
Create a new instrumented appender using the given registry name.- Parameters:
registryName
- the name of the registry inSharedMetricRegistries
-
InstrumentedAppender
public InstrumentedAppender(MetricRegistry registry)
Create a new instrumented appender using the given registry.- Parameters:
registry
- the metric registry
-
InstrumentedAppender
public InstrumentedAppender(MetricRegistry registry, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions)
Create a new instrumented appender using the given registry.- Parameters:
registry
- the metric registryfilter
- The Filter to associate with the Appender.layout
- The layout to use to format the event.ignoreExceptions
- If true, exceptions will be logged and suppressed. If false errors will be logged and then passed to the application.
-
InstrumentedAppender
public InstrumentedAppender(String appenderName, MetricRegistry registry)
Create a new instrumented appender using the given appender name and registry.- Parameters:
appenderName
- The name of the appender.registry
- the metric registry
-
-
Method Detail
-
createAppender
@PluginFactory public static InstrumentedAppender createAppender(@PluginAttribute("name") String name, @PluginAttribute(value="registryName",defaultString="log4j2Metrics") String registry)
-
start
public void start()
- Specified by:
start
in interfaceorg.apache.logging.log4j.core.LifeCycle
- Overrides:
start
in classorg.apache.logging.log4j.core.filter.AbstractFilterable
-
append
public void append(org.apache.logging.log4j.core.LogEvent event)
-
-