Interface AppenderAdminMBean

All Known Implementing Classes:
AppenderAdmin

public interface AppenderAdminMBean
The MBean interface for monitoring and managing an Appender.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    ObjectName pattern ("org.apache.logging.log4j2:type=%s,component=Appenders,name=%s") for AppenderAdmin MBeans.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the result of calling toString on the error handler of this appender, or "null" if no error handler was set.
    Returns a string description of all filters configured for the instrumented Appender.
    Returns the result of calling toString on the Layout object of the instrumented Appender.
    Returns the name of the instrumented Appender.
    boolean
    Returns how exceptions thrown on the instrumented Appender are handled.
  • Field Details

    • PATTERN

      static final String PATTERN
      ObjectName pattern ("org.apache.logging.log4j2:type=%s,component=Appenders,name=%s") for AppenderAdmin MBeans. This pattern contains two variables, where the first is the name of the context, the second is the name of the instrumented appender.

      You can find all registered AppenderAdmin MBeans like this:

       MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
       String pattern = String.format(AppenderAdminMBean.PATTERN, "*", "*");
       Set<ObjectName> appenderNames = mbs.queryNames(new ObjectName(pattern), null);
       

      Some characters are not allowed in ObjectNames. The logger context name and appender name may be quoted. When AppenderAdmin MBeans are registered, their ObjectNames are created using this pattern as follows:

       String ctxName = Server.escape(loggerContext.getName());
       String appenderName = Server.escape(appender.getName());
       String name = String.format(PATTERN, ctxName, appenderName);
       ObjectName objectName = new ObjectName(name);
       
      See Also:
  • Method Details

    • getName

      String getName()
      Returns the name of the instrumented Appender.
      Returns:
      the name of the Appender
    • getLayout

      String getLayout()
      Returns the result of calling toString on the Layout object of the instrumented Appender.
      Returns:
      the Layout of the instrumented Appender as a string
    • isIgnoreExceptions

      boolean isIgnoreExceptions()
      Returns how exceptions thrown on the instrumented Appender are handled.
      Returns:
      true if any exceptions thrown by the Appender will be logged or false if such exceptions are re-thrown.
    • getErrorHandler

      String getErrorHandler()
      Returns the result of calling toString on the error handler of this appender, or "null" if no error handler was set.
      Returns:
      result of calling toString on the error handler of this appender, or "null"
    • getFilter

      String getFilter()
      Returns a string description of all filters configured for the instrumented Appender.
      Returns:
      a string description of all configured filters for this appender