Package org.swisspush.gateleen.logging
Class Log4jConfiguratorMBean
- java.lang.Object
-
- org.swisspush.gateleen.logging.Log4jConfiguratorMBean
-
- All Implemented Interfaces:
java.lang.Cloneable,javax.management.DynamicMBean,CloneableDynamicMBean
public class Log4jConfiguratorMBean extends java.lang.Object implements CloneableDynamicMBean
MBean used to dynamically configure log4j. Simply all known and named loggers - including the root logger - are exposed as attributes of this MBean. The attribute's values represent the current level of the appropriate logger. Hint: This component itself uses log4j as the logging framework.- Author:
- schwabmar
- See Also:
Log4jConfigurator
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringASTERISKAsterisk used as trailing string for inherited logging levels.static java.lang.StringDEFAULT_JMX_NAMEDefault name.
-
Constructor Summary
Constructors Constructor Description Log4jConfiguratorMBean()Default constructor for Log4jConfiguratorMBean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Creates a clone of the object.java.lang.ObjectgetAttribute(java.lang.String attribute)Gets the value of an attribute and thus the level of a certain logger.javax.management.AttributeListgetAttributes(java.lang.String[] attributes)Gets the values of several attributes.javax.management.MBeanInfogetMBeanInfo()Returns all informations on the MBean, such as attributes and operations.java.lang.Objectinvoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)Invokes an operation on the MBean.voidsetAttribute(javax.management.Attribute attribute)Sets the value of an attribute.javax.management.AttributeListsetAttributes(javax.management.AttributeList attributes)Sets the values of several attributes.java.lang.StringsetLoggerLevel(java.lang.String pattern, java.lang.String level)Directly sets a level on one ore more loggers.
-
-
-
Field Detail
-
ASTERISK
public static final java.lang.String ASTERISK
Asterisk used as trailing string for inherited logging levels.- See Also:
- Constant Field Values
-
DEFAULT_JMX_NAME
public static final java.lang.String DEFAULT_JMX_NAME
Default name. This is the value of the name part of this MBean's JMX object name.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAttribute
public java.lang.Object getAttribute(java.lang.String attribute) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionExceptionGets the value of an attribute and thus the level of a certain logger. If the logger hasn't got an assigned level, the level from the parent logger trailed with an asterisk is returned.- Specified by:
getAttributein interfacejavax.management.DynamicMBean- Throws:
javax.management.AttributeNotFoundExceptionjavax.management.MBeanExceptionjavax.management.ReflectionException- See Also:
DynamicMBean.getAttribute(String)
-
setAttribute
public void setAttribute(javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionExceptionSets the value of an attribute.- Specified by:
setAttributein interfacejavax.management.DynamicMBean- Throws:
javax.management.AttributeNotFoundExceptionjavax.management.InvalidAttributeValueExceptionjavax.management.MBeanExceptionjavax.management.ReflectionException- See Also:
DynamicMBean.setAttribute(Attribute)
-
getAttributes
public javax.management.AttributeList getAttributes(java.lang.String[] attributes)
Gets the values of several attributes. Delegates the work to the methodgetAttribute.- Specified by:
getAttributesin interfacejavax.management.DynamicMBean- See Also:
getAttribute(String),DynamicMBean.getAttributes(String[])
-
setAttributes
public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Sets the values of several attributes. Delegates the work to the methodsetAttribute.- Specified by:
setAttributesin interfacejavax.management.DynamicMBean- See Also:
setAttribute(Attribute),DynamicMBean.setAttributes(AttributeList)
-
invoke
public java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws javax.management.MBeanException, javax.management.ReflectionExceptionInvokes an operation on the MBean. This method is generically implemented - it simply tries to call a method named <actionName> with the provided parameters.- Specified by:
invokein interfacejavax.management.DynamicMBean- Throws:
javax.management.MBeanExceptionjavax.management.ReflectionException- See Also:
DynamicMBean.invoke(String, Object[], String[])
-
getMBeanInfo
public javax.management.MBeanInfo getMBeanInfo()
Returns all informations on the MBean, such as attributes and operations.- Specified by:
getMBeanInfoin interfacejavax.management.DynamicMBean- See Also:
getAttributeInfo(),getConstructorInfo(),getOperationInfo(),getNotificationInfo(),DynamicMBean.getMBeanInfo()
-
setLoggerLevel
public java.lang.String setLoggerLevel(java.lang.String pattern, java.lang.String level)Directly sets a level on one ore more loggers. Therefore the loggers to modify are selected via a pattern - all loggers with a name matching the provided pattern are set to the new level.
Example: ^org\.swisspush\..* matches all names beginning with org.swisspush (this is the exact expression - in almost every case this expression can be simplified to ^org.swisspush.*).
This method is only invoked by theinvokemethod of this class and has to be public (since it is called via reflection API).- Parameters:
pattern- Regular expression used to select the loggers.level- New level.- Returns:
- The total number of modified loggers.
- See Also:
Level,invoke(String, Object[], String[]),getOperationInfo()
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionCreates a clone of the object.- Specified by:
clonein interfaceCloneableDynamicMBean- Overrides:
clonein classjava.lang.Object- Returns:
- The MBean's clone.
- Throws:
java.lang.CloneNotSupportedException
-
-