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
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final StatusLoggerprivate final LoggerContextprivate final ObjectNameprivate static final intprivate final AtomicLongprivate static final intFields inherited from interface org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean
NOTIF_TYPE_RECONFIGURED, PATTERN -
Constructor Summary
ConstructorsConstructorDescriptionLoggerContextAdmin(LoggerContext loggerContext, Executor executor) Constructs a newLoggerContextAdminwith theExecutorto be used for sendingNotifications asynchronously to listeners. -
Method Summary
Modifier and TypeMethodDescriptionprivate static MBeanNotificationInfoprivate ConfigurationReturns the class name of theConfigurationof the instrumented LoggerContext.Returns a string description of all Filters configured in theConfigurationof 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 theObjectNameof this mbean.Returns the status of the instrumentedLoggerContext.private longprivate longnow()voidprivate StringreadContents(InputStream in, Charset charset) Returns the contents of the specified input stream as a String.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
-
Field Details
-
PAGE
private static final int PAGE- See Also:
-
TEXT_BUFFER
private static final int TEXT_BUFFER- See Also:
-
BUFFER_SIZE
private static final int BUFFER_SIZE- See Also:
-
LOGGER
-
sequenceNo
-
objectName
-
loggerContext
-
-
Constructor Details
-
LoggerContextAdmin
Constructs a newLoggerContextAdminwith theExecutorto be used for sendingNotifications asynchronously to listeners.- Parameters:
loggerContext- the instrumented objectexecutor- used to send notifications asynchronously
-
-
Method Details
-
createNotificationInfo
-
getStatus
Description copied from interface:LoggerContextAdminMBeanReturns the status of the instrumentedLoggerContext.- Specified by:
getStatusin interfaceLoggerContextAdminMBean- Returns:
- the LoggerContext status.
-
getName
Description copied from interface:LoggerContextAdminMBeanReturns the name of the instrumentedLoggerContext.- Specified by:
getNamein interfaceLoggerContextAdminMBean- Returns:
- the name of the instrumented
LoggerContext.
-
getConfig
-
getConfigLocationUri
Description copied from interface:LoggerContextAdminMBeanReturns the configuration location URI as a String.- Specified by:
getConfigLocationUriin interfaceLoggerContextAdminMBean- Returns:
- the configuration location
-
setConfigLocationUri
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
- Specified by:
propertyChangein interfacePropertyChangeListener
-
getConfigText
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
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.
-
readContents
Returns the contents of the specified input stream as a String.- Parameters:
in- stream to read fromcharset- MUST not be null- Returns:
- stream contents
- Throws:
IOException- if a problem occurred reading from the stream.
-
setConfigText
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
Description copied from interface:LoggerContextAdminMBeanReturns the name of the Configuration of the instrumented LoggerContext.- Specified by:
getConfigNamein interfaceLoggerContextAdminMBean- Returns:
- the Configuration name
-
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
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
Description copied from interface:LoggerContextAdminMBeanReturns a map with configured properties.- Specified by:
getConfigPropertiesin interfaceLoggerContextAdminMBean- Returns:
- a map with configured properties.
-
getObjectName
Returns theObjectNameof this mbean.- Specified by:
getObjectNamein interfaceLoggerContextAdminMBean- Returns:
- the
ObjectName - See Also:
-
nextSeqNo
private long nextSeqNo() -
now
private long now()
-