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 String
static final String
The domain part, or prefix ("org.apache.logging.log4j2") of theObjectName
of all MBeans that instrument Log4J2 components.(package private) static final Executor
private static final StatusLogger
private static final String
private static final String
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ExecutorService
Returns either anull
Executor (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 String
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.private static ContextSelector
Returns theContextSelector
of the currentLog4jContextFactory
.private static boolean
private static void
register
(MBeanServer mbs, Object mbean, ObjectName objectName) private static void
registerAppenders
(LoggerContext ctx, MBeanServer mbs, Executor executor) private static void
registerContextSelector
(String contextName, ContextSelector selector, MBeanServer mbs, Executor executor) private static void
registerLoggerConfigs
(LoggerContext ctx, MBeanServer mbs, Executor executor) private static void
registerStatusLogger
(String contextName, MBeanServer mbs, Executor executor) static void
static void
private static void
unregisterAllMatching
(String search, MBeanServer mbs) private static void
unregisterAppenders
(String contextName, MBeanServer mbs) private static void
unregisterAsyncAppenders
(String contextName, MBeanServer mbs) private static void
unregisterAsyncLoggerConfigRingBufferAdmins
(String contextName, MBeanServer mbs) private static void
unregisterAsyncLoggerRingBufferAdmins
(String contextName, MBeanServer mbs) private static void
private static void
unregisterContextSelector
(String contextName, MBeanServer mbs) private static void
unregisterLoggerConfigs
(String contextName, MBeanServer mbs) static void
unregisterLoggerContext
(String loggerContextName) Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfig
s andAppender
s from the platform MBean server.static void
unregisterLoggerContext
(String contextName, MBeanServer mbs) Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfig
s andAppender
s from the platform MBean server.static void
Unregister all log4j MBeans from the platform MBean server.static void
Unregister all log4j MBeans from the specified MBean server.private static void
unregisterStatusLogger
(String contextName, MBeanServer mbs)
-
Field Details
-
CONTEXT_NAME_ALL
- See Also:
-
DOMAIN
The domain part, or prefix ("org.apache.logging.log4j2") of theObjectName
of 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 anull
Executor (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 anull
Executor 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 theContextSelector
of the currentLog4jContextFactory
.- Returns:
- the
ContextSelector
of the currentLog4jContextFactory
-
unregisterLoggerContext
Unregisters all MBeans associated with the specified logger context (including MBeans forLoggerConfig
s andAppender
s 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 forLoggerConfig
s andAppender
s 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
-