Class StatusLoggerAdmin
java.lang.Object
javax.management.NotificationBroadcasterSupport
org.apache.logging.log4j.core.jmx.StatusLoggerAdmin
- All Implemented Interfaces:
Closeable
,AutoCloseable
,EventListener
,MBeanRegistration
,NotificationBroadcaster
,NotificationEmitter
,StatusLoggerAdminMBean
,StatusListener
public class StatusLoggerAdmin
extends NotificationBroadcasterSupport
implements StatusListener, StatusLoggerAdminMBean, MBeanRegistration
Implementation of the
StatusLoggerAdminMBean
interface.-
Field Summary
Fields inherited from interface org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean
NOTIF_TYPE_DATA, NOTIF_TYPE_MESSAGE, PATTERN
-
Constructor Summary
ConstructorDescriptionStatusLoggerAdmin
(String contextName, Executor executor) Constructs a newStatusLoggerAdmin
with theExecutor
to be used for sendingNotification
s asynchronously to listeners. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNotificationListener
(NotificationListener listener, NotificationFilter filter, Object handback) void
close()
Returns the name of the LoggerContext that theStatusLogger
is associated with.getLevel()
Returns theStatusLogger
level as a String.Returns theObjectName
of this mbean.Returns a list with the most recentStatusData
objects in the status history.String[]
Returns a string array with the most recent messages in the status history.void
log
(StatusData data) void
void
postRegister
(Boolean registrationDone) void
preRegister
(MBeanServer server, ObjectName name) void
Sets theStatusLogger
level to the specified value.Methods inherited from class javax.management.NotificationBroadcasterSupport
getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
-
Constructor Details
-
StatusLoggerAdmin
Constructs a newStatusLoggerAdmin
with theExecutor
to be used for sendingNotification
s asynchronously to listeners.- Parameters:
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 asynchronously
-
-
Method Details
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) - Specified by:
addNotificationListener
in interfaceNotificationBroadcaster
- Overrides:
addNotificationListener
in classNotificationBroadcasterSupport
-
preRegister
- Specified by:
preRegister
in interfaceMBeanRegistration
-
postRegister
- Specified by:
postRegister
in interfaceMBeanRegistration
-
preDeregister
public void preDeregister()- Specified by:
preDeregister
in interfaceMBeanRegistration
-
postDeregister
public void postDeregister()- Specified by:
postDeregister
in interfaceMBeanRegistration
-
getStatusDataHistory
Description copied from interface:StatusLoggerAdminMBean
Returns a string array with the most recent messages 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"
.- Specified by:
getStatusDataHistory
in interfaceStatusLoggerAdminMBean
- Returns:
- the most recent messages logged by the
StatusLogger
.
-
getStatusData
Description copied from interface:StatusLoggerAdminMBean
Returns a list with the most recentStatusData
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.- Specified by:
getStatusData
in interfaceStatusLoggerAdminMBean
- Returns:
- the most recent messages logged by the
StatusLogger
.
-
getLevel
Description copied from interface:StatusLoggerAdminMBean
Returns theStatusLogger
level as a String.- Specified by:
getLevel
in interfaceStatusLoggerAdminMBean
- Returns:
- the
StatusLogger
level.
-
getStatusLevel
- Specified by:
getStatusLevel
in interfaceStatusListener
-
setLevel
Description copied from interface:StatusLoggerAdminMBean
Sets theStatusLogger
level to the specified value.- Specified by:
setLevel
in interfaceStatusLoggerAdminMBean
- Parameters:
level
- the newStatusLogger
level.
-
getContextName
Description copied from interface:StatusLoggerAdminMBean
Returns the name of the LoggerContext that theStatusLogger
is associated with.- Specified by:
getContextName
in interfaceStatusLoggerAdminMBean
- Returns:
- logger context name
-
log
- Specified by:
log
in interfaceStatusListener
-
getObjectName
Returns theObjectName
of this mbean.- Specified by:
getObjectName
in interfaceStatusLoggerAdminMBean
- Returns:
- the
ObjectName
- See Also:
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-