Interface LoggerContextAdminMBean
-
- All Known Implementing Classes:
LoggerContextAdmin
public interface LoggerContextAdminMBeanThe MBean interface for monitoring and managing aLoggerContext.
-
-
Field Summary
Fields Modifier and Type Field Description static StringNOTIF_TYPE_RECONFIGUREDNotification that theConfigurationof the instrumentedLoggerContexthas been reconfigured.static StringPATTERNObjectName pattern ("org.apache.logging.log4j2:type=%s" ) for LoggerContextAdmin MBeans.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetConfigClassName()Returns the class name of theConfigurationof the instrumented LoggerContext.StringgetConfigFilter()Returns a string description of all Filters configured in theConfigurationof the instrumented LoggerContext.StringgetConfigLocationUri()Returns the configuration location URI as a String.StringgetConfigName()Returns the name of the Configuration of the instrumented LoggerContext.Map<String,String>getConfigProperties()Returns a map with configured properties.StringgetConfigText()Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call tosetConfigText.StringgetConfigText(String charsetName)Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call tosetConfigText.StringgetName()Returns the name of the instrumentedLoggerContext.ObjectNamegetObjectName()Returns theObjectNamethat this MBean is registered with in the MBean server.StringgetStatus()Returns the status of the instrumentedLoggerContext.voidsetConfigLocationUri(String configLocation)Sets the configuration location to the specified URI.voidsetConfigText(String configText, String charsetName)Sets the configuration text.
-
-
-
Field Detail
-
PATTERN
static final String PATTERN
ObjectName pattern ("org.apache.logging.log4j2:type=%s" ) for LoggerContextAdmin MBeans. This pattern contains a variable, which is the name of the logger context.You can find all registered LoggerContextAdmin MBeans like this:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); String pattern = String.format(LoggerContextAdminMBean.PATTERN, "*"); Set<ObjectName> loggerContextNames = mbs.queryNames(new ObjectName(pattern), null);
Some characters are not allowed in ObjectNames. The logger context name may be quoted. When LoggerContextAdmin 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_RECONFIGURED
static final String NOTIF_TYPE_RECONFIGURED
Notification that theConfigurationof the instrumentedLoggerContexthas been reconfigured. Notifications of this type ("com.apache.logging.log4j.core.jmx.config.reconfigured" ) do not carry a message or user data.- See Also:
- Constant Field Values
-
-
Method Detail
-
getObjectName
ObjectName getObjectName()
Returns theObjectNamethat this MBean is registered with in the MBean server.
-
getStatus
String getStatus()
Returns the status of the instrumentedLoggerContext.- Returns:
- the LoggerContext status.
-
getName
String getName()
Returns the name of the instrumentedLoggerContext.- Returns:
- the name of the instrumented
LoggerContext.
-
getConfigLocationUri
String getConfigLocationUri()
Returns the configuration location URI as a String.- Returns:
- the configuration location
-
setConfigLocationUri
void setConfigLocationUri(String configLocation) throws URISyntaxException, IOException
Sets the configuration location to the specified URI. This will cause the instrumentedLoggerContextto reconfigure.- Parameters:
configLocation- location of the configuration file inURIformat.- Throws:
URISyntaxException- if the format of the specified configLocationURI is incorrectIOException- if an error occurred reading the specified location
-
getConfigText
String getConfigText() throws IOException
Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call tosetConfigText. If reading a file, this method assumes the file's character encoding is UTF-8.- Returns:
- the configuration text
- Throws:
IOException- if a problem occurred reading the contents of the config file.
-
getConfigText
String getConfigText(String charsetName) throws IOException
Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call tosetConfigText.- Parameters:
charsetName- the encoding to use to convert the file's bytes into the resulting string.- Returns:
- the configuration text
- Throws:
IOException- if a problem occurred reading the contents of the config file.
-
setConfigText
void setConfigText(String configText, String charsetName)
Sets the configuration text. This does not replace the contents of the configuration file, but does cause the instrumentedLoggerContextto be reconfigured with the specified text.- Parameters:
configText- the configuration text in XML or JSON formatcharsetName- name of theCharsetused to convert the specified configText to bytes- Throws:
IllegalArgumentException- if a problem occurs configuring from the specified text
-
getConfigName
String getConfigName()
Returns the name of the Configuration of the instrumented LoggerContext.- Returns:
- the Configuration name
-
getConfigClassName
String getConfigClassName()
Returns the class name of theConfigurationof the instrumented LoggerContext.- Returns:
- the class name of the
Configuration.
-
getConfigFilter
String getConfigFilter()
Returns a string description of all Filters configured in theConfigurationof the instrumented LoggerContext.- Returns:
- a string description of all Filters configured
-
-