Class LoggerContextAdmin
java.lang.Object
javax.management.NotificationBroadcasterSupport
org.apache.logging.log4j.core.jmx.LoggerContextAdmin
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,NotificationBroadcaster
,NotificationEmitter
,LoggerContextAdminMBean
public class LoggerContextAdmin
extends NotificationBroadcasterSupport
implements LoggerContextAdminMBean, PropertyChangeListener
Implementation of the
LoggerContextAdminMBean
interface.-
Field Summary
Fields inherited from interface org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean
NOTIF_TYPE_RECONFIGURED, PATTERN
-
Constructor Summary
ConstructorDescriptionLoggerContextAdmin
(LoggerContext loggerContext, Executor executor) Constructs a newLoggerContextAdmin
with theExecutor
to be used for sendingNotification
s asynchronously to listeners. -
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
of this mbean.Returns the status of the instrumentedLoggerContext
.void
void
setConfigLocationUri
(String configLocation) Sets the configuration location to the specified URI.void
setConfigText
(String configText, String charsetName) Sets the configuration text.Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
-
Constructor Details
-
LoggerContextAdmin
Constructs a newLoggerContextAdmin
with theExecutor
to be used for sendingNotification
s asynchronously to listeners.- Parameters:
executor
- used to send notifications asynchronouslyloggerContext
- the instrumented object
-
-
Method Details
-
getStatus
Description copied from interface:LoggerContextAdminMBean
Returns the status of the instrumentedLoggerContext
.- Specified by:
getStatus
in interfaceLoggerContextAdminMBean
- Returns:
- the LoggerContext status.
-
getName
Description copied from interface:LoggerContextAdminMBean
Returns the name of the instrumentedLoggerContext
.- Specified by:
getName
in interfaceLoggerContextAdminMBean
- Returns:
- the name of the instrumented
LoggerContext
.
-
getConfigLocationUri
Description copied from interface:LoggerContextAdminMBean
Returns the configuration location URI as a String.- Specified by:
getConfigLocationUri
in interfaceLoggerContextAdminMBean
- Returns:
- the configuration location
-
setConfigLocationUri
Description copied from interface:LoggerContextAdminMBean
Sets the configuration location to the specified URI. This will cause the instrumentedLoggerContext
to reconfigure.- Specified by:
setConfigLocationUri
in interfaceLoggerContextAdminMBean
- 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
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
getConfigText
Description copied from interface:LoggerContextAdminMBean
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.- Specified by:
getConfigText
in interfaceLoggerContextAdminMBean
- Returns:
- the configuration text
- Throws:
IOException
- if a problem occurred reading the contents of the config file.
-
getConfigText
Description copied from interface:LoggerContextAdminMBean
Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call tosetConfigText
.- Specified by:
getConfigText
in interfaceLoggerContextAdminMBean
- 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
Description copied from interface:LoggerContextAdminMBean
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.- Specified by:
setConfigText
in interfaceLoggerContextAdminMBean
- Parameters:
configText
- the configuration text in XML or JSON formatcharsetName
- name of theCharset
used to convert the specified configText to bytes
-
getConfigName
Description copied from interface:LoggerContextAdminMBean
Returns the name of the Configuration of the instrumented LoggerContext.- Specified by:
getConfigName
in interfaceLoggerContextAdminMBean
- Returns:
- the Configuration name
-
getConfigClassName
Description copied from interface:LoggerContextAdminMBean
Returns the class name of theConfiguration
of the instrumented LoggerContext.- Specified by:
getConfigClassName
in interfaceLoggerContextAdminMBean
- Returns:
- the class name of the
Configuration
.
-
getConfigFilter
Description copied from interface:LoggerContextAdminMBean
Returns a string description of all Filters configured in theConfiguration
of the instrumented LoggerContext.- Specified by:
getConfigFilter
in interfaceLoggerContextAdminMBean
- Returns:
- a string description of all Filters configured
-
getConfigProperties
Description copied from interface:LoggerContextAdminMBean
Returns a map with configured properties.- Specified by:
getConfigProperties
in interfaceLoggerContextAdminMBean
- Returns:
- a map with configured properties.
-
getObjectName
Returns theObjectName
of this mbean.- Specified by:
getObjectName
in interfaceLoggerContextAdminMBean
- Returns:
- the
ObjectName
- See Also:
-