Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.logging
Class Log4jService

    java.lang.Object
      org.jboss.mx.util.JBossNotificationBroadcasterSupport
          org.jboss.system.ServiceMBeanSupport
              org.jboss.logging.Log4jService

All Implemented Interfaces:
  Log4jServiceMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class Log4jService
extends org.jboss.system.ServiceMBeanSupport
implements Log4jServiceMBean

Initializes the Log4j logging framework. Supports XML and standard configuration file formats. Defaults to using 'log4j.xml' read from a system resource.

Sets up a `ThrowableListener` to adapt unhandled throwables to a logger.

Installs `LoggerStream` adapters for `System.out` and `System.err` to catch and redirect calls to Log4j.

Version:
  `$Revision: 1.27 $`
Author:
  Fulco Muriglio, Scott Stark, David Jencks, Jason Dillon

Field Summary
`static boolean` | `CATCH_SYSTEM_ERR` Default flag to enable/disable cacthing System.err.
`static boolean` | `CATCH_SYSTEM_OUT` Default flag to enable/disable cacthing System.out.
`static String` | `DEFAULT_URL` The default url for the configuration file.

Fields inherited from class org.jboss.system.ServiceMBeanSupport
`log, server, SERVICE_CONTROLLER_SIG, serviceName`

Fields inherited from interface org.jboss.logging.Log4jServiceMBean
`OBJECT_NAME`

Fields inherited from interface org.jboss.system.ServiceMBean
`CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED`

Constructor Summary
`Log4jService()` Uses defaults.
`Log4jService(String url)`
`Log4jService(String url, int refreshPeriod)`
`Log4jService(URL url)`
`Log4jService(URL url, int refreshPeriod)`

Method Summary
`protected void` | `createService()`
`boolean` | `getCatchSystemErr()` Get the catch `System.err` flag.
`boolean` | `getCatchSystemOut()` Get the catch `System.out` flag.
`URL` | `getConfigurationURL()` Get the Log4j configuration URL.
`boolean` | `getLog4jQuietMode()` Get the org.apache.log4j.helpers.LogLog.setQuietMode flag
`String` | `getLoggerLevel(String name)` Gets the level of the logger of the give name.
`protected javax.management.ObjectName` | `getObjectName(javax.management.MBeanServer server, javax.management.ObjectName name)`
`int` | `getRefreshPeriod()` Get the refresh period.
`void` | `reconfigure()` Force the logging system to reconfigure.
`void` | `reconfigure(String url)` Hack to reconfigure and change the URL.
`void` | `setCatchSystemErr(boolean flag)` Set the catch `System.err` flag.
`void` | `setCatchSystemOut(boolean flag)` Set the catch `System.out` flag.
`void` | `setConfigurationURL(URL url)` Set the Log4j configuration URL.
`void` | `setLog4jQuietMode(boolean flag)` Set the org.apache.log4j.helpers.LogLog.setQuietMode flag
`void` | `setLoggerLevel(String name, String levelName)` Sets the level for a logger of the give name.
`void` | `setLoggerLevels(String list, String levelName)` Sets the levels of each logger specified by the given comma seperated list of logger names.
`void` | `setRefreshPeriod(int refreshPeriod)` Set the refresh period.
`protected void` | `startService()`
`protected void` | `stopService()`

Methods inherited from class org.jboss.system.ServiceMBeanSupport
`create, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop`

Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
`addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jboss.system.ServiceMBean
`getName, getState, getStateString, jbossInternalLifecycle`

Methods inherited from interface org.jboss.system.Service
`create, destroy, start, stop`

Field Detail

### DEFAULT_URL

    public static final String DEFAULT_URL

  The default url for the configuration file. Reads the value from the system property `org.jboss.logging.Log4jService.configURL` or if that is not set defaults to `resource:log4j.xml`.

### CATCH_SYSTEM_OUT

    public static final boolean CATCH_SYSTEM_OUT

  Default flag to enable/disable cacthing System.out. Reads the value from the system property `org.jboss.logging.Log4jService.catchSystemOut` or if not set defaults to `true`.

### CATCH_SYSTEM_ERR

    public static final boolean CATCH_SYSTEM_ERR

  Default flag to enable/disable cacthing System.err. Reads the value from the system property `org.jboss.logging.Log4jService.catchSystemErr` or if not set defaults to `true`.

Constructor Detail

### Log4jService

    public Log4jService()
                 throws MalformedURLException

  Uses defaults.

Throws:
  `MalformedURLException` - Could not create URL from default (propbably a problem with overridden properties).

### Log4jService

    public Log4jService(URL url)

Parameters:
  `url` - The configuration URL.

### Log4jService

    public Log4jService(String url)
                 throws MalformedURLException

Parameters:
  `url` - The configuration URL.

### Log4jService

    public Log4jService(String url,
                        int refreshPeriod)
                 throws MalformedURLException

Parameters:
  `url` - The configuration URL.
  `refreshPeriod` - The refreshPeriod in seconds to wait between each check.

### Log4jService

    public Log4jService(URL url,
                        int refreshPeriod)

Parameters:
  `url` - The configuration URL.
  `refreshPeriod` - The refreshPeriod in seconds to wait between each check.

Method Detail

### setCatchSystemOut

    public void setCatchSystemOut(boolean flag)

  Set the catch `System.out` flag.

  Specified by:
    `setCatchSystemOut` in interface `Log4jServiceMBean`
  Parameters:
    `flag` - True to enable, false to disable.

### getCatchSystemOut

    public boolean getCatchSystemOut()

  Get the catch `System.out` flag.

  Specified by:
    `getCatchSystemOut` in interface `Log4jServiceMBean`
  Returns:
    True if enabled, false if disabled.

### setCatchSystemErr

    public void setCatchSystemErr(boolean flag)

  Set the catch `System.err` flag.

  Specified by:
    `setCatchSystemErr` in interface `Log4jServiceMBean`
  Parameters:
    `flag` - True to enable, false to disable.

### getCatchSystemErr

    public boolean getCatchSystemErr()

  Get the catch `System.err` flag.

  Specified by:
    `getCatchSystemErr` in interface `Log4jServiceMBean`
  Returns:
    True if enabled, false if disabled.

### getLog4jQuietMode

    public boolean getLog4jQuietMode()

  Get the org.apache.log4j.helpers.LogLog.setQuietMode flag

  Specified by:
    `getLog4jQuietMode` in interface `Log4jServiceMBean`
  Returns:
    True if enabled, false if disabled.

### setLog4jQuietMode

    public void setLog4jQuietMode(boolean flag)

  Set the org.apache.log4j.helpers.LogLog.setQuietMode flag

  Specified by:
    `setLog4jQuietMode` in interface `Log4jServiceMBean`
  Returns:
    True if enabled, false if disabled.

### getRefreshPeriod

    public int getRefreshPeriod()

  Get the refresh period.

  Specified by:
    `getRefreshPeriod` in interface `Log4jServiceMBean`

### setRefreshPeriod

    public void setRefreshPeriod(int refreshPeriod)

  Set the refresh period.

  Specified by:
    `setRefreshPeriod` in interface `Log4jServiceMBean`

### getConfigurationURL

    public URL getConfigurationURL()

  Get the Log4j configuration URL.

  Specified by:
    `getConfigurationURL` in interface `Log4jServiceMBean`

### setConfigurationURL

    public void setConfigurationURL(URL url)

  Set the Log4j configuration URL.

  Specified by:
    `setConfigurationURL` in interface `Log4jServiceMBean`

### setLoggerLevel

    public void setLoggerLevel(String name,
                               String levelName)

  Sets the level for a logger of the give name.

  Values are trimmed before used.

  Specified by:
    `setLoggerLevel` in interface `Log4jServiceMBean`
  Parameters:
    `name` - The name of the logger to change level
    `levelName` - The name of the level to change the logger to.

### setLoggerLevels

    public void setLoggerLevels(String list,
                                String levelName)

  Sets the levels of each logger specified by the given comma seperated list of logger names.

  Specified by:
    `setLoggerLevels` in interface `Log4jServiceMBean`
  Parameters:
    `list` - A comma seperated list of logger names.
    `levelName` - The name of the level to change the logger to.
  See Also:
    `setLoggerLevel(java.lang.String, java.lang.String)`

### getLoggerLevel

    public String getLoggerLevel(String name)

  Gets the level of the logger of the give name.

  Specified by:
    `getLoggerLevel` in interface `Log4jServiceMBean`
  Parameters:
    `name` - The name of the logger to inspect.

### reconfigure

    public void reconfigure()
                     throws IOException

  Force the logging system to reconfigure.

  Specified by:
    `reconfigure` in interface `Log4jServiceMBean`
  Throws:
    `IOException`

### reconfigure

    public void reconfigure(String url)
                     throws IOException,
                            MalformedURLException

  Hack to reconfigure and change the URL. This is needed until we have a JMX HTML Adapter that can use PropertyEditor to coerce.

  Specified by:
    `reconfigure` in interface `Log4jServiceMBean`
  Parameters:
    `url` - The new configuration url
  Throws:
    `IOException`
    `MalformedURLException`

### getObjectName

    protected javax.management.ObjectName getObjectName(javax.management.MBeanServer server,
                                                        javax.management.ObjectName name)
                                                 throws javax.management.MalformedObjectNameException

  Throws:
    `javax.management.MalformedObjectNameException`

### createService

    protected void createService()
                          throws Exception

  Throws:
    `Exception`

### startService

    protected void startService()
                         throws Exception

  Throws:
    `Exception`

### stopService

    protected void stopService()
                        throws Exception

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.