public class StatusLoggerAdmin extends javax.management.NotificationBroadcasterSupport implements StatusListener, StatusLoggerAdminMBean
StatusLoggerAdminMBean
interface.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
contextName |
private Level |
level |
private javax.management.ObjectName |
objectName |
private java.util.concurrent.atomic.AtomicLong |
sequenceNo |
NOTIF_TYPE_DATA, NOTIF_TYPE_MESSAGE, PATTERN
Constructor and Description |
---|
StatusLoggerAdmin(java.lang.String contextName,
java.util.concurrent.Executor executor)
Constructs a new
StatusLoggerAdmin with the Executor to
be used for sending Notification s asynchronously to listeners. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
private static javax.management.MBeanNotificationInfo |
createNotificationInfo() |
java.lang.String |
getContextName()
Returns the name of the LoggerContext that the
StatusLogger is associated with. |
java.lang.String |
getLevel()
Returns the
StatusLogger level as a String. |
javax.management.ObjectName |
getObjectName()
Returns the
ObjectName of this mbean. |
java.util.List<StatusData> |
getStatusData()
Returns a list with the most recent
StatusData objects in the
status history. |
java.lang.String[] |
getStatusDataHistory()
Returns a string array with the most recent messages in the status
history.
|
Level |
getStatusLevel()
Return the Log Level that this listener wants included.
|
void |
log(StatusData data)
Called as events occur to process the StatusData.
|
private long |
nextSeqNo() |
private long |
nowMillis() |
private void |
removeListeners(java.lang.String ctxName)
Add listener to StatusLogger for this context, or replace it if it already exists.
|
void |
setLevel(java.lang.String level)
Sets the
StatusLogger level to the specified value. |
private final java.util.concurrent.atomic.AtomicLong sequenceNo
private final javax.management.ObjectName objectName
private final java.lang.String contextName
private Level level
public StatusLoggerAdmin(java.lang.String contextName, java.util.concurrent.Executor executor)
StatusLoggerAdmin
with the Executor
to
be used for sending Notification
s asynchronously to listeners.contextName
- name of the LoggerContext under which to register this
StatusLoggerAdmin. Note that the StatusLogger may be
registered multiple times, once for each LoggerContext. In web
containers, each web application has its own LoggerContext and
by associating the StatusLogger with the LoggerContext, all
associated MBeans can be unloaded when the web application is
undeployed.executor
- used to send notifications asynchronouslyprivate void removeListeners(java.lang.String ctxName)
ctxName
- private static javax.management.MBeanNotificationInfo createNotificationInfo()
public java.lang.String[] getStatusDataHistory()
StatusLoggerAdminMBean
"log4j2.status.entries"
.getStatusDataHistory
in interface StatusLoggerAdminMBean
StatusLogger
.public java.util.List<StatusData> getStatusData()
StatusLoggerAdminMBean
StatusData
objects in the
status history. The list has up to 200 entries by default but the length
can be configured with system property "log4j2.status.entries"
.
Note that the returned objects may contain Throwable
s from
external libraries.
JMX clients calling this method must be prepared to deal with the errors
that occur if they do not have the class definition for such
Throwable
s in their classpath.
getStatusData
in interface StatusLoggerAdminMBean
StatusLogger
.public java.lang.String getLevel()
StatusLoggerAdminMBean
StatusLogger
level as a String.getLevel
in interface StatusLoggerAdminMBean
StatusLogger
level.public Level getStatusLevel()
StatusListener
getStatusLevel
in interface StatusListener
public void setLevel(java.lang.String level)
StatusLoggerAdminMBean
StatusLogger
level to the specified value.setLevel
in interface StatusLoggerAdminMBean
level
- the new StatusLogger
level.public java.lang.String getContextName()
StatusLoggerAdminMBean
StatusLogger
is associated with.getContextName
in interface StatusLoggerAdminMBean
public void log(StatusData data)
StatusListener
log
in interface StatusListener
data
- The StatusData for the event.public javax.management.ObjectName getObjectName()
ObjectName
of this mbean.getObjectName
in interface StatusLoggerAdminMBean
ObjectName
StatusLoggerAdminMBean.PATTERN
private long nextSeqNo()
private long nowMillis()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException