Class Server
java.lang.Object
org.apache.logging.log4j.core.jmx.Server
Creates MBeans to instrument various classes in the log4j class hierarchy.
All instrumentation for Log4j 2 classes can be disabled by setting system property -Dlog4j2.disable.jmx=true.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringstatic final StringThe domain part, or prefix ("org.apache.logging.log4j2") of theObjectNameof all MBeans that instrument Log4J2 components.(package private) static final Executorprivate static final StatusLoggerprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ExecutorServiceReturns either anullExecutor (causing JMX notifications to be sent from the caller thread) or a daemon background thread Executor, depending on the value of system property "log4j2.jmx.notify.async".static StringEither returns the specified name as is, or returns a quoted value containing the specified name with the special characters (comma, equals, colon, quote, asterisk, or question mark) preceded with a backslash.private static ContextSelectorReturns theContextSelectorof the currentLog4jContextFactory.private static booleanprivate static voidregister(MBeanServer mbs, Object mbean, ObjectName objectName) private static voidregisterAppenders(LoggerContext ctx, MBeanServer mbs, Executor executor) private static voidregisterContextSelector(String contextName, ContextSelector selector, MBeanServer mbs, Executor executor) private static voidregisterLoggerConfigs(LoggerContext ctx, MBeanServer mbs, Executor executor) private static voidregisterStatusLogger(String contextName, MBeanServer mbs, Executor executor) static voidstatic voidprivate static voidunregisterAllMatching(String search, MBeanServer mbs) private static voidunregisterAppenders(String contextName, MBeanServer mbs) private static voidunregisterAsyncAppenders(String contextName, MBeanServer mbs) private static voidunregisterAsyncLoggerConfigRingBufferAdmins(String contextName, MBeanServer mbs) private static voidunregisterAsyncLoggerRingBufferAdmins(String contextName, MBeanServer mbs) private static voidprivate static voidunregisterContextSelector(String contextName, MBeanServer mbs) private static voidunregisterLoggerConfigs(String contextName, MBeanServer mbs) static voidunregisterLoggerContext(String loggerContextName) Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfigs andAppenders from the platform MBean server.static voidunregisterLoggerContext(String contextName, MBeanServer mbs) Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfigs andAppenders from the platform MBean server.static voidUnregister all log4j MBeans from the platform MBean server.static voidUnregister all log4j MBeans from the specified MBean server.private static voidunregisterStatusLogger(String contextName, MBeanServer mbs)
-
Field Details
-
CONTEXT_NAME_ALL
- See Also:
-
DOMAIN
The domain part, or prefix ("org.apache.logging.log4j2") of theObjectNameof all MBeans that instrument Log4J2 components.- See Also:
-
PROPERTY_DISABLE_JMX
- See Also:
-
PROPERTY_ASYNC_NOTIF
- See Also:
-
THREAD_NAME_PREFIX
- See Also:
-
LOGGER
-
executor
-
-
Constructor Details
-
Server
private Server()
-
-
Method Details
-
createExecutor
Returns either anullExecutor (causing JMX notifications to be sent from the caller thread) or a daemon background thread Executor, depending on the value of system property "log4j2.jmx.notify.async". If this property is not set, use anullExecutor for web apps to avoid memory leaks and other issues when the web app is restarted.- See Also:
-
escape
Either returns the specified name as is, or returns a quoted value containing the specified name with the special characters (comma, equals, colon, quote, asterisk, or question mark) preceded with a backslash.- Parameters:
name- the name to escape so it can be used as a value in anObjectName.- Returns:
- the escaped name
-
isJmxDisabled
private static boolean isJmxDisabled() -
reregisterMBeansAfterReconfigure
public static void reregisterMBeansAfterReconfigure() -
reregisterMBeansAfterReconfigure
-
unregisterMBeans
public static void unregisterMBeans()Unregister all log4j MBeans from the platform MBean server. -
unregisterMBeans
Unregister all log4j MBeans from the specified MBean server.- Parameters:
mbs- the MBean server to unregister from.
-
getContextSelector
Returns theContextSelectorof the currentLog4jContextFactory.- Returns:
- the
ContextSelectorof the currentLog4jContextFactory
-
unregisterLoggerContext
Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfigs andAppenders from the platform MBean server.- Parameters:
loggerContextName- name of the logger context to unregister
-
unregisterLoggerContext
Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfigs andAppenders from the platform MBean server.- Parameters:
contextName- name of the logger context to unregistermbs- the MBean Server to unregister the instrumented objects from
-
registerStatusLogger
private static void registerStatusLogger(String contextName, MBeanServer mbs, Executor executor) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException -
registerContextSelector
private static void registerContextSelector(String contextName, ContextSelector selector, MBeanServer mbs, Executor executor) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException -
unregisterStatusLogger
-
unregisterContextSelector
-
unregisterLoggerConfigs
-
unregisterContexts
-
unregisterAppenders
-
unregisterAsyncAppenders
-
unregisterAsyncLoggerRingBufferAdmins
-
unregisterAsyncLoggerConfigRingBufferAdmins
private static void unregisterAsyncLoggerConfigRingBufferAdmins(String contextName, MBeanServer mbs) -
unregisterAllMatching
-
registerLoggerConfigs
private static void registerLoggerConfigs(LoggerContext ctx, MBeanServer mbs, Executor executor) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException -
registerAppenders
private static void registerAppenders(LoggerContext ctx, MBeanServer mbs, Executor executor) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException -
register
private static void register(MBeanServer mbs, Object mbean, ObjectName objectName) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
-