Interface LoggerContextAdminMBean
-
- All Known Implementing Classes:
LoggerContextAdmin
public interface LoggerContextAdminMBean
The MBean interface for monitoring and managing aLoggerContext
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
NOTIF_TYPE_RECONFIGURED
Notification that theConfiguration
of the instrumentedLoggerContext
has been reconfigured.static String
PATTERN
ObjectName pattern ("org.apache.logging.log4j2:type=%s" ) for LoggerContextAdmin MBeans.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getConfigClassName()
Returns the class name of theConfiguration
of the instrumented LoggerContext.String
getConfigFilter()
Returns a string description of all Filters configured in theConfiguration
of the instrumented LoggerContext.String
getConfigLocationUri()
Returns the configuration location URI as a String.String
getConfigName()
Returns the name of the Configuration of the instrumented LoggerContext.Map<String,String>
getConfigProperties()
Returns a map with configured properties.String
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
.String
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
.String
getName()
Returns the name of the instrumentedLoggerContext
.ObjectName
getObjectName()
Returns theObjectName
that this MBean is registered with in the MBean server.String
getStatus()
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 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 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:
- Constant Field Values
-
-
Method Detail
-
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
void setConfigLocationUri(String configLocation) throws URISyntaxException, IOException
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
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 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
-
-