Package org.swisspush.gateleen.logging
Class Log4jConfiguratorMBean
- java.lang.Object
-
- org.swisspush.gateleen.logging.Log4jConfiguratorMBean
-
- All Implemented Interfaces:
Cloneable,DynamicMBean,CloneableDynamicMBean
public class Log4jConfiguratorMBean extends 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 StringASTERISKAsterisk used as trailing string for inherited logging levels.static 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 Objectclone()Creates a clone of the object.ObjectgetAttribute(String attribute)Gets the value of an attribute and thus the level of a certain logger.AttributeListgetAttributes(String[] attributes)Gets the values of several attributes.MBeanInfogetMBeanInfo()Returns all informations on the MBean, such as attributes and operations.Objectinvoke(String actionName, Object[] params, String[] signature)Invokes an operation on the MBean.voidsetAttribute(Attribute attribute)Sets the value of an attribute.AttributeListsetAttributes(AttributeList attributes)Sets the values of several attributes.StringsetLoggerLevel(String pattern, String level)Directly sets a level on one ore more loggers.
-
-
-
Field Detail
-
ASTERISK
public static final String ASTERISK
Asterisk used as trailing string for inherited logging levels.- See Also:
- Constant Field Values
-
DEFAULT_JMX_NAME
public static final 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 Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
Gets 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 interfaceDynamicMBean- Throws:
AttributeNotFoundExceptionMBeanExceptionReflectionException- See Also:
DynamicMBean.getAttribute(String)
-
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
Sets the value of an attribute.- Specified by:
setAttributein interfaceDynamicMBean- Throws:
AttributeNotFoundExceptionInvalidAttributeValueExceptionMBeanExceptionReflectionException- See Also:
DynamicMBean.setAttribute(Attribute)
-
getAttributes
public AttributeList getAttributes(String[] attributes)
Gets the values of several attributes. Delegates the work to the methodgetAttribute.- Specified by:
getAttributesin interfaceDynamicMBean- See Also:
getAttribute(String),DynamicMBean.getAttributes(String[])
-
setAttributes
public AttributeList setAttributes(AttributeList attributes)
Sets the values of several attributes. Delegates the work to the methodsetAttribute.- Specified by:
setAttributesin interfaceDynamicMBean- See Also:
setAttribute(Attribute),DynamicMBean.setAttributes(AttributeList)
-
invoke
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
Invokes 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 interfaceDynamicMBean- Throws:
MBeanExceptionReflectionException- See Also:
DynamicMBean.invoke(String, Object[], String[])
-
getMBeanInfo
public MBeanInfo getMBeanInfo()
Returns all informations on the MBean, such as attributes and operations.- Specified by:
getMBeanInfoin interfaceDynamicMBean- See Also:
getAttributeInfo(),getConstructorInfo(),getOperationInfo(),getNotificationInfo(),DynamicMBean.getMBeanInfo()
-
setLoggerLevel
public String setLoggerLevel(String pattern, 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:
- "org.apache.log4j.Level",
invoke(String, Object[], String[]),getOperationInfo()
-
clone
public Object clone() throws CloneNotSupportedException
Creates a clone of the object.- Specified by:
clonein interfaceCloneableDynamicMBean- Overrides:
clonein classObject- Returns:
- The MBean's clone.
- Throws:
CloneNotSupportedException
-
-