ch.elca.el4j.services.monitoring.jmx
Class Log4jConfig

java.lang.Object
  extended by ch.elca.el4j.services.monitoring.jmx.Log4jConfig
All Implemented Interfaces:
Log4jConfigMBean

public class Log4jConfig
extends Object
implements Log4jConfigMBean

The logging proxy class, for setting logging properties via JMX.

Author:
Rashid Waraich (RWA)
File-location:
Log4jConfig
Last check-in date:
2010-01-15 14:26:34 +0100 (Fr, 15. Jan 2010) by jonasha for revision 4093

Field Summary
static String JVM_DOMAIN
          The domain of the Logger bean proxy as it will be registered at the MBean Server.
static String LOG4J_JMX_LOADER
          The name of the 'log4jJmxLoader' bean.
protected  ApplicationContext m_applicationContext
          The Application Context where this Spring Bean is registered at.
protected  ApplicationContextMB m_applicationContextMB
          The Application Context proxy for the real Application Context.
protected  BeanFactory m_beanFactory
          The Bean Factory belonging to the referenced Application Context.
protected  Class m_class
          The class name of this class.
 
Constructor Summary
Log4jConfig(String name, ApplicationContextMB acMB, ApplicationContext ac, BeanFactory beanFactory, MBeanServer mBeanServer)
          Constructor.
 
Method Summary
 void addAppender(String category, String appenderName)
          Add appender to the specified logger category.
 void changeLogLevel(String category, String level)
          Changes the log level for a category or creates a new category if the supplied category name doesn't exist.
 String[] getAvailableAppendersList()
          For all loaded appenders, a String representaion of the appenderName and appenderObject is returned.
 String getInitialConfigurationPath()
          Get the path of the log4j configuration file, which was loaded initially (at application start).
 int getInstanceCounter()
          The getter method for the instanceCounter member.
 String getName()
          Getter method for the name member variable.
 ObjectName getObjectName()
          Getter method for the objectName member variable.
 String getRootLoggerLevel()
          Gives back the level of the root logger.
 void init()
          
protected  void registerSpringBean()
          Register this SpringBean at the MBean Server.
 void removeAppender(String category, String appenderName)
          Remove appender from the specified logger category.
 void setAppendersPool(HashMap appenders)
           
 void setInstanceCounter()
          Save the class variable s_counter to an instance member and increment the class variable by 1.
 void setObjectName()
          Sets the objectName to of this object.
 void setRootLoggerLevel(String level)
          Sets the level of the root logger.
 org.apache.log4j.Appender[] showAppenders(String category)
          Return the appenders of the specified Logger category.
 org.apache.log4j.Level showLogLevel(String category)
          Return the log level of the Logger category.
 String showLogLevelCache()
          Shows the XML representation of all changes made to any logger level through the JMX interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JVM_DOMAIN

public static final String JVM_DOMAIN
The domain of the Logger bean proxy as it will be registered at the MBean Server.

See Also:
Constant Field Values

LOG4J_JMX_LOADER

public static final String LOG4J_JMX_LOADER
The name of the 'log4jJmxLoader' bean.

See Also:
Constant Field Values

m_applicationContext

protected ApplicationContext m_applicationContext
The Application Context where this Spring Bean is registered at.


m_applicationContextMB

protected ApplicationContextMB m_applicationContextMB
The Application Context proxy for the real Application Context.


m_class

protected Class m_class
The class name of this class.


m_beanFactory

protected BeanFactory m_beanFactory
The Bean Factory belonging to the referenced Application Context.

Constructor Detail

Log4jConfig

public Log4jConfig(String name,
                   ApplicationContextMB acMB,
                   ApplicationContext ac,
                   BeanFactory beanFactory,
                   MBeanServer mBeanServer)
Constructor.

Parameters:
name - The bean definition name of this Spring Bean
acMB - The Application Context proxy
ac - The real Application Context
beanFactory - The Bean Factory belonging to this Application Context
mBeanServer - The MBean Server where this Spring Bean is registered at
Method Detail

init

public void init()
          throws BaseException

Throws:
BaseException

registerSpringBean

protected void registerSpringBean()
                           throws BaseException
Register this SpringBean at the MBean Server.

Throws:
BaseException - in case the registration at the MBean Server failed

getObjectName

public ObjectName getObjectName()
Getter method for the objectName member variable.

Returns:
The objectName

setObjectName

public void setObjectName()
Sets the objectName to of this object.


getName

public String getName()
Getter method for the name member variable.

Specified by:
getName in interface Log4jConfigMBean
Returns:
Returns the name.

setAppendersPool

public void setAppendersPool(HashMap appenders)
Parameters:
appenders - The appeenders list.

addAppender

public void addAppender(String category,
                        String appenderName)
Add appender to the specified logger category.

Specified by:
addAppender in interface Log4jConfigMBean
Parameters:
category - The category of the logger.
appenderName - The name of the appender to be removed.

removeAppender

public void removeAppender(String category,
                           String appenderName)
Remove appender from the specified logger category.

Specified by:
removeAppender in interface Log4jConfigMBean
Parameters:
category - The category of the logger.
appenderName - The name of the appender to be removed.

getAvailableAppendersList

public String[] getAvailableAppendersList()
For all loaded appenders, a String representaion of the appenderName and appenderObject is returned.

Specified by:
getAvailableAppendersList in interface Log4jConfigMBean
Returns:
The available appenders.

changeLogLevel

public void changeLogLevel(String category,
                           String level)
Changes the log level for a category or creates a new category if the supplied category name doesn't exist.

Specified by:
changeLogLevel in interface Log4jConfigMBean
Parameters:
category - The category of the logger.
level - The level of the logger to be set.

showLogLevel

public org.apache.log4j.Level showLogLevel(String category)
Return the log level of the Logger category.

Specified by:
showLogLevel in interface Log4jConfigMBean
Parameters:
category - The category.
Returns:
The level.

showAppenders

public org.apache.log4j.Appender[] showAppenders(String category)
Return the appenders of the specified Logger category.

Specified by:
showAppenders in interface Log4jConfigMBean
Parameters:
category - The category.
Returns:
The appenders.

setRootLoggerLevel

public void setRootLoggerLevel(String level)
Sets the level of the root logger.

Specified by:
setRootLoggerLevel in interface Log4jConfigMBean
Parameters:
level - The logging level.

getRootLoggerLevel

public String getRootLoggerLevel()
Gives back the level of the root logger.

Specified by:
getRootLoggerLevel in interface Log4jConfigMBean
Returns:
The logging level.

showLogLevelCache

public String showLogLevelCache()
Shows the XML representation of all changes made to any logger level through the JMX interface.

Specified by:
showLogLevelCache in interface Log4jConfigMBean
Returns:
HTML embeddable XML (suitable for pasting in log4j.xml)

getInitialConfigurationPath

public String getInitialConfigurationPath()
Get the path of the log4j configuration file, which was loaded initially (at application start).

Specified by:
getInitialConfigurationPath in interface Log4jConfigMBean
Returns:
The path of the configuration file.

getInstanceCounter

public int getInstanceCounter()
The getter method for the instanceCounter member.

Returns:
The instanceCounter member

setInstanceCounter

public void setInstanceCounter()
Save the class variable s_counter to an instance member and increment the class variable by 1.



Copyright © 2005-2011 ELCA. All Rights Reserved.