Interface LoggerContextAdminMBean
- All Known Implementing Classes:
LoggerContextAdmin
public interface LoggerContextAdminMBean
The MBean interface for monitoring and managing a
LoggerContext
.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the class name of theConfiguration
of the instrumented LoggerContext.Returns a string description of all Filters configured in theConfiguration
of the instrumented LoggerContext.Returns the configuration location URI as a String.Returns the name of the Configuration of the instrumented LoggerContext.Returns a map with configured properties.Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call tosetConfigText
.getConfigText
(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
.getName()
Returns the name of the instrumentedLoggerContext
.Returns theObjectName
that this MBean is registered with in the MBean server.Returns the status of the instrumentedLoggerContext
.void
setConfigLocationUri
(String configLocation) Sets the configuration location to the specified URI.void
setConfigText
(String configText, String charsetName) Sets the configuration text.
-
Field Details
-
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:
-
NOTIF_TYPE_RECONFIGURED
Notification that theConfiguration
of the instrumentedLoggerContext
has been reconfigured. Notifications of this type ("com.apache.logging.log4j.core.jmx.config.reconfigured" ) do not carry a message or user data.- See Also:
-
-
Method Details
-
getObjectName
ObjectName getObjectName()Returns theObjectName
that 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
Sets the configuration location to the specified URI. This will cause the instrumentedLoggerContext
to reconfigure.- Parameters:
configLocation
- location of the configuration file inURI
format.- Throws:
URISyntaxException
- if the format of the specified configLocationURI is incorrectIOException
- if an error occurred reading the specified location
-
getConfigText
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
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
Sets the configuration text. This does not replace the contents of the configuration file, but does cause the instrumentedLoggerContext
to be reconfigured with the specified text.- Parameters:
configText
- the configuration text in XML or JSON formatcharsetName
- name of theCharset
used 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 theConfiguration
of the instrumented LoggerContext.- Returns:
- the class name of the
Configuration
.
-
getConfigFilter
String getConfigFilter()Returns a string description of all Filters configured in theConfiguration
of the instrumented LoggerContext.- Returns:
- a string description of all Filters configured
-
getConfigProperties
Returns a map with configured properties.- Returns:
- a map with configured properties.
-