public class CountingConsoleAppender
extends org.apache.log4j.ConsoleAppender
ConsoleAppender
, invoking the empty constructor
on this class will set a default layout (DEFAULT_LAYOUT
).Modifier and Type | Field and Description |
---|---|
static org.apache.log4j.Layout |
DEFAULT_LAYOUT |
Constructor and Description |
---|
CountingConsoleAppender() |
CountingConsoleAppender(org.apache.log4j.Layout layout) |
CountingConsoleAppender(org.apache.log4j.Layout layout,
String target) |
Modifier and Type | Method and Description |
---|---|
void |
append(org.apache.log4j.spi.LoggingEvent event) |
int |
getCount()
Gets the number of events logged for all log levels.
|
int |
getCount(org.apache.log4j.Level level)
Gets the number of events logged for the given log level.
|
boolean |
isEmpty()
Whether this appender counted any log events.
|
void |
reset()
Resets all counts to zero.
|
void |
startCountingFor(Class<?> clazz,
org.apache.log4j.Level logLevel)
Starts counting log events for a class by creating a logger for that
class and appending itself to it.
|
void |
stopCountingFor(Class<?> clazz)
Stops counting log events for a class by removing this appender
from the logger previously created for the supplied class.
|
String |
toString() |
activateOptions, closeWriter, getFollow, getTarget, setFollow, setTarget
checkEntryConditions, close, createWriter, getEncoding, getImmediateFlush, requiresLayout, setEncoding, setErrorHandler, setImmediateFlush, setWriter, shouldFlush, subAppend, writeFooter, writeHeader
public CountingConsoleAppender()
public CountingConsoleAppender(org.apache.log4j.Layout layout, String target)
public CountingConsoleAppender(org.apache.log4j.Layout layout)
public void append(org.apache.log4j.spi.LoggingEvent event)
append
in class org.apache.log4j.WriterAppender
public boolean isEmpty()
true
if an event was loggedpublic int getCount(org.apache.log4j.Level level)
level
- log levelpublic int getCount()
public void reset()
reset
in class org.apache.log4j.WriterAppender
public void startCountingFor(Class<?> clazz, org.apache.log4j.Level logLevel)
clazz
- class to count log events forlogLevel
- minimum log level to trackpublic void stopCountingFor(Class<?> clazz)
startCountingFor(Class, Level)
was not previously invoked with the same class.clazz
- class to stop counting log events forCopyright © 2008–2021 Norconex Inc.. All rights reserved.