Interface StatusLoggerAdminMBean
-
- All Known Implementing Classes:
StatusLoggerAdmin
public interface StatusLoggerAdminMBeanThe MBean interface for monitoring and managing theStatusLogger.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNOTIF_TYPE_DATANotifications with this type have aStatusDatauserData object and anullmessage.static java.lang.StringNOTIF_TYPE_MESSAGENotifications with this type have a formatted status data message string but noStatusDatain their userData field.static java.lang.StringPATTERNObjectName pattern ("org.apache.logging.log4j2:type=%s,component=StatusLogger") for StatusLoggerAdmin MBeans.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetContextName()Returns the name of the LoggerContext that theStatusLoggeris associated with.java.lang.StringgetLevel()Returns theStatusLoggerlevel as a String.javax.management.ObjectNamegetObjectName()Returns theObjectNamethat this status logger mbean is registered with.java.util.List<StatusData>getStatusData()Returns a list with the most recentStatusDataobjects in the status history.java.lang.String[]getStatusDataHistory()Returns a string array with the most recent messages in the status history.voidsetLevel(java.lang.String level)Sets theStatusLoggerlevel to the specified value.
-
-
-
Field Detail
-
PATTERN
static final java.lang.String PATTERN
ObjectName pattern ("org.apache.logging.log4j2:type=%s,component=StatusLogger") for StatusLoggerAdmin MBeans. This pattern contains a variable, which is the name of the logger context.You can find all registered StatusLoggerAdmin MBeans like this:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); String pattern = String.format(StatusLoggerAdminMBean.PATTERN, "*"); Set<ObjectName> statusLoggerNames = mbs.queryNames(new ObjectName(pattern), null);
Some characters are not allowed in ObjectNames. The logger context name may be quoted. When StatusLoggerAdmin MBeans are registered, their ObjectNames are created using this pattern as follows:
String ctxName = Server.escape(loggerContext.getName()); String name = String.format(PATTERN, ctxName); ObjectName objectName = new ObjectName(name);
- See Also:
Server.escape(String), Constant Field Values
-
NOTIF_TYPE_DATA
static final java.lang.String NOTIF_TYPE_DATA
Notifications with this type have aStatusDatauserData object and anullmessage.- See Also:
- Constant Field Values
-
NOTIF_TYPE_MESSAGE
static final java.lang.String NOTIF_TYPE_MESSAGE
Notifications with this type have a formatted status data message string but noStatusDatain their userData field.- See Also:
- Constant Field Values
-
-
Method Detail
-
getObjectName
javax.management.ObjectName getObjectName()
Returns theObjectNamethat this status logger mbean is registered with.- Returns:
- the ObjectName of this StatusLogger MBean
-
getStatusData
java.util.List<StatusData> getStatusData()
Returns a list with the most recentStatusDataobjects 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
Throwables 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
Throwables in their classpath.- Returns:
- the most recent messages logged by the
StatusLogger.
-
getStatusDataHistory
java.lang.String[] getStatusDataHistory()
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".- Returns:
- the most recent messages logged by the
StatusLogger.
-
getLevel
java.lang.String getLevel()
Returns theStatusLoggerlevel as a String.- Returns:
- the
StatusLoggerlevel.
-
setLevel
void setLevel(java.lang.String level)
Sets theStatusLoggerlevel to the specified value.- Parameters:
level- the newStatusLoggerlevel.- Throws:
java.lang.IllegalArgumentException- if the specified level is not one of "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"
-
getContextName
java.lang.String getContextName()
Returns the name of the LoggerContext that theStatusLoggeris associated with.- Returns:
- logger context name
-
-