Class Server


  • public final class Server
    extends java.lang.Object
    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

      Fields 
      Modifier and Type Field Description
      static java.lang.String DOMAIN
      The domain part, or prefix ("org.apache.logging.log4j2") of the ObjectName of all MBeans that instrument Log4J2 components.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escape​(java.lang.String name)
      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.
      static void reregisterMBeansAfterReconfigure()  
      static void reregisterMBeansAfterReconfigure​(javax.management.MBeanServer mbs)  
      static void unregisterLoggerContext​(java.lang.String loggerContextName)
      Unregisters all MBeans associated with the specified logger context (including MBeans for LoggerConfigs and Appenders from the platform MBean server.
      static void unregisterLoggerContext​(java.lang.String contextName, javax.management.MBeanServer mbs)
      Unregisters all MBeans associated with the specified logger context (including MBeans for LoggerConfigs and Appenders from the platform MBean server.
      static void unregisterMBeans()
      Unregister all log4j MBeans from the platform MBean server.
      static void unregisterMBeans​(javax.management.MBeanServer mbs)
      Unregister all log4j MBeans from the specified MBean server.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DOMAIN

        public static final java.lang.String DOMAIN
        The domain part, or prefix ("org.apache.logging.log4j2") of the ObjectName of all MBeans that instrument Log4J2 components.
        See Also:
        Constant Field Values
    • Method Detail

      • escape

        public static java.lang.String escape​(java.lang.String name)
        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 an ObjectName.
        Returns:
        the escaped name
      • reregisterMBeansAfterReconfigure

        public static void reregisterMBeansAfterReconfigure()
      • reregisterMBeansAfterReconfigure

        public static void reregisterMBeansAfterReconfigure​(javax.management.MBeanServer mbs)
      • unregisterMBeans

        public static void unregisterMBeans()
        Unregister all log4j MBeans from the platform MBean server.
      • unregisterMBeans

        public static void unregisterMBeans​(javax.management.MBeanServer mbs)
        Unregister all log4j MBeans from the specified MBean server.
        Parameters:
        mbs - the MBean server to unregister from.
      • unregisterLoggerContext

        public static void unregisterLoggerContext​(java.lang.String loggerContextName)
        Unregisters all MBeans associated with the specified logger context (including MBeans for LoggerConfigs and Appenders from the platform MBean server.
        Parameters:
        loggerContextName - name of the logger context to unregister
      • unregisterLoggerContext

        public static void unregisterLoggerContext​(java.lang.String contextName,
                                                   javax.management.MBeanServer mbs)
        Unregisters all MBeans associated with the specified logger context (including MBeans for LoggerConfigs and Appenders from the platform MBean server.
        Parameters:
        contextName - name of the logger context to unregister
        mbs - the MBean Server to unregister the instrumented objects from