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 java.lang.StringNOTIF_TYPE_RECONFIGUREDNotification that theConfigurationof the instrumentedLoggerContexthas been reconfigured.static java.lang.StringPATTERNObjectName pattern ("org.apache.logging.log4j2:type=%s" ) for LoggerContextAdmin MBeans.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetConfigClassName()Returns the class name of theConfigurationof the instrumented LoggerContext.java.lang.StringgetConfigFilter()Returns a string description of all Filters configured in theConfigurationof the instrumented LoggerContext.java.lang.StringgetConfigLocationUri()Returns the configuration location URI as a String.java.lang.StringgetConfigName()Returns the name of the Configuration of the instrumented LoggerContext.java.util.Map<java.lang.String,java.lang.String>getConfigProperties()Returns a map with configured properties.java.lang.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.java.lang.StringgetConfigText(java.lang.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.java.lang.StringgetName()Returns the name of the instrumentedLoggerContext.javax.management.ObjectNamegetObjectName()Returns theObjectNamethat this MBean is registered with in the MBean server.java.lang.StringgetStatus()Returns the status of the instrumentedLoggerContext.voidsetConfigLocationUri(java.lang.String configLocation)Sets the configuration location to the specified URI.voidsetConfigText(java.lang.String configText, java.lang.String charsetName)Sets the configuration text.
-
-
-
Field Detail
-
PATTERN
static final java.lang.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 java.lang.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
javax.management.ObjectName getObjectName()
Returns theObjectNamethat this MBean is registered with in the MBean server.
-
getStatus
java.lang.String getStatus()
Returns the status of the instrumentedLoggerContext.- Returns:
- the LoggerContext status.
-
getName
java.lang.String getName()
Returns the name of the instrumentedLoggerContext.- Returns:
- the name of the instrumented
LoggerContext.
-
getConfigLocationUri
java.lang.String getConfigLocationUri()
Returns the configuration location URI as a String.- Returns:
- the configuration location
-
setConfigLocationUri
void setConfigLocationUri(java.lang.String configLocation) throws java.net.URISyntaxException, java.io.IOExceptionSets the configuration location to the specified URI. This will cause the instrumentedLoggerContextto reconfigure.- Parameters:
configLocation- location of the configuration file inURIformat.- Throws:
java.net.URISyntaxException- if the format of the specified configLocationURI is incorrectjava.io.IOException- if an error occurred reading the specified location
-
getConfigText
java.lang.String getConfigText() throws java.io.IOExceptionReturns 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:
java.io.IOException- if a problem occurred reading the contents of the config file.
-
getConfigText
java.lang.String getConfigText(java.lang.String charsetName) throws java.io.IOExceptionReturns 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:
java.io.IOException- if a problem occurred reading the contents of the config file.
-
setConfigText
void setConfigText(java.lang.String configText, java.lang.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:
java.lang.IllegalArgumentException- if a problem occurs configuring from the specified text
-
getConfigName
java.lang.String getConfigName()
Returns the name of the Configuration of the instrumented LoggerContext.- Returns:
- the Configuration name
-
getConfigClassName
java.lang.String getConfigClassName()
Returns the class name of theConfigurationof the instrumented LoggerContext.- Returns:
- the class name of the
Configuration.
-
getConfigFilter
java.lang.String getConfigFilter()
Returns a string description of all Filters configured in theConfigurationof the instrumented LoggerContext.- Returns:
- a string description of all Filters configured
-
getConfigProperties
java.util.Map<java.lang.String,java.lang.String> getConfigProperties()
Returns a map with configured properties.- Returns:
- a map with configured properties.
-
-