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 theLoggerContextAdminMBean
interface.
-
-
Field Summary
-
Fields inherited from interface org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean
NOTIF_TYPE_RECONFIGURED, PATTERN
-
-
Constructor Summary
Constructors Constructor Description LoggerContextAdmin(LoggerContext loggerContext, Executor executor)
Constructs a newLoggerContextAdmin
with theExecutor
to be used for sendingNotification
s asynchronously to listeners.
-
Method Summary
All Methods Instance Methods Concrete 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
of this mbean.String
getStatus()
Returns the status of the instrumentedLoggerContext
.void
propertyChange(PropertyChangeEvent evt)
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 Detail
-
LoggerContextAdmin
public LoggerContextAdmin(LoggerContext loggerContext, Executor executor)
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 Detail
-
getStatus
public String getStatus()
Description copied from interface:LoggerContextAdminMBean
Returns the status of the instrumentedLoggerContext
.- Specified by:
getStatus
in interfaceLoggerContextAdminMBean
- Returns:
- the LoggerContext status.
-
getName
public String 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
public String getConfigLocationUri()
Description copied from interface:LoggerContextAdminMBean
Returns the configuration location URI as a String.- Specified by:
getConfigLocationUri
in interfaceLoggerContextAdminMBean
- Returns:
- the configuration location
-
setConfigLocationUri
public void setConfigLocationUri(String configLocation) throws URISyntaxException, IOException
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
public void propertyChange(PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
getConfigText
public String getConfigText() throws IOException
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
public String getConfigText(String charsetName) throws IOException
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
public void setConfigText(String configText, String charsetName)
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
public String 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
public String 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
public String 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
public Map<String,String> getConfigProperties()
Description copied from interface:LoggerContextAdminMBean
Returns a map with configured properties.- Specified by:
getConfigProperties
in interfaceLoggerContextAdminMBean
- Returns:
- a map with configured properties.
-
getObjectName
public ObjectName getObjectName()
Returns theObjectName
of this mbean.- Specified by:
getObjectName
in interfaceLoggerContextAdminMBean
- Returns:
- the
ObjectName
- See Also:
LoggerContextAdminMBean.PATTERN
-
-