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 theLoggerContextAdminMBeaninterface.
-
-
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 newLoggerContextAdminwith theExecutorto be used for sendingNotifications asynchronously to listeners.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetConfigClassName()Returns the class name of theConfigurationof the instrumented LoggerContext.StringgetConfigFilter()Returns a string description of all Filters configured in theConfigurationof the instrumented LoggerContext.StringgetConfigLocationUri()Returns the configuration location URI as a String.StringgetConfigName()Returns the name of the Configuration of the instrumented LoggerContext.Map<String,String>getConfigProperties()Returns a map with configured properties.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.StringgetConfigText(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.StringgetName()Returns the name of the instrumentedLoggerContext.ObjectNamegetObjectName()Returns theObjectNameof this mbean.StringgetStatus()Returns the status of the instrumentedLoggerContext.voidpropertyChange(PropertyChangeEvent evt)voidsetConfigLocationUri(String configLocation)Sets the configuration location to the specified URI.voidsetConfigText(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 newLoggerContextAdminwith theExecutorto be used for sendingNotifications asynchronously to listeners.- Parameters:
executor- used to send notifications asynchronouslyloggerContext- the instrumented object
-
-
Method Detail
-
getStatus
public String getStatus()
Description copied from interface:LoggerContextAdminMBeanReturns the status of the instrumentedLoggerContext.- Specified by:
getStatusin interfaceLoggerContextAdminMBean- Returns:
- the LoggerContext status.
-
getName
public String getName()
Description copied from interface:LoggerContextAdminMBeanReturns the name of the instrumentedLoggerContext.- Specified by:
getNamein interfaceLoggerContextAdminMBean- Returns:
- the name of the instrumented
LoggerContext.
-
getConfigLocationUri
public String getConfigLocationUri()
Description copied from interface:LoggerContextAdminMBeanReturns the configuration location URI as a String.- Specified by:
getConfigLocationUriin interfaceLoggerContextAdminMBean- Returns:
- the configuration location
-
setConfigLocationUri
public void setConfigLocationUri(String configLocation) throws URISyntaxException, IOException
Description copied from interface:LoggerContextAdminMBeanSets the configuration location to the specified URI. This will cause the instrumentedLoggerContextto reconfigure.- Specified by:
setConfigLocationUriin interfaceLoggerContextAdminMBean- Parameters:
configLocation- location of the configuration file inURIformat.- 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:
propertyChangein interfacePropertyChangeListener
-
getConfigText
public String getConfigText() throws IOException
Description copied from interface:LoggerContextAdminMBeanReturns 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:
getConfigTextin 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:LoggerContextAdminMBeanReturns 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:
getConfigTextin 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:LoggerContextAdminMBeanSets the configuration text. This does not replace the contents of the configuration file, but does cause the instrumentedLoggerContextto be reconfigured with the specified text.- Specified by:
setConfigTextin interfaceLoggerContextAdminMBean- Parameters:
configText- the configuration text in XML or JSON formatcharsetName- name of theCharsetused to convert the specified configText to bytes
-
getConfigName
public String getConfigName()
Description copied from interface:LoggerContextAdminMBeanReturns the name of the Configuration of the instrumented LoggerContext.- Specified by:
getConfigNamein interfaceLoggerContextAdminMBean- Returns:
- the Configuration name
-
getConfigClassName
public String getConfigClassName()
Description copied from interface:LoggerContextAdminMBeanReturns the class name of theConfigurationof the instrumented LoggerContext.- Specified by:
getConfigClassNamein interfaceLoggerContextAdminMBean- Returns:
- the class name of the
Configuration.
-
getConfigFilter
public String getConfigFilter()
Description copied from interface:LoggerContextAdminMBeanReturns a string description of all Filters configured in theConfigurationof the instrumented LoggerContext.- Specified by:
getConfigFilterin interfaceLoggerContextAdminMBean- Returns:
- a string description of all Filters configured
-
getConfigProperties
public Map<String,String> getConfigProperties()
Description copied from interface:LoggerContextAdminMBeanReturns a map with configured properties.- Specified by:
getConfigPropertiesin interfaceLoggerContextAdminMBean- Returns:
- a map with configured properties.
-
getObjectName
public ObjectName getObjectName()
Returns theObjectNameof this mbean.- Specified by:
getObjectNamein interfaceLoggerContextAdminMBean- Returns:
- the
ObjectName - See Also:
LoggerContextAdminMBean.PATTERN
-
-