org.jboss.logging
Class Log4jService

public class Log4jService
extends 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.

SinceNot specified.
Version<tt>$Revis
Author<a href="mailto:phox@galactica.it">Fulco Muriglio</a>, <a href="mailto:Scott_Stark@displayscape.com">Scott Stark</a>, <a href="mailto:davidjencks@earthlink.net">David Jencks</a>, <a href="mailto:jason@planet57.com">Jason Dillon</a>
Wiki javadoc Use textile entry format.
Add your comments here.
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 org.jboss.systemServiceMBeanSupport
Constructor Summary
Log4jService()
Uses defaults.
Log4jService( URL url )
No description provided.
Log4jService( String url )
No description provided.
Log4jService( String url, int refreshPeriod )
No description provided.
Log4jService( URL url, int refreshPeriod )
No description provided.
Method Summary
protected void createService()
No description provided.
protected void emitReconfigureNotification()
No description provided.
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 ObjectName getObjectName( MBeanServer server, ObjectName name )
No description provided.
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()
No description provided.
protected void stopService()
No description provided.
CATCH_SYSTEM_ERR
public static 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.
Wiki javadoc Use textile entry format.
Add your comments here.
CATCH_SYSTEM_OUT
public static 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.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_URL
public static 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.
Wiki javadoc Use textile entry format.
Add your comments here.
Log4jService
public Log4jService ( )
Uses defaults.
Exceptions
MalformedURLException Could not create URL from default (propbably a problem with overridden properties).
Wiki javadoc Use textile entry format.
Add your comments here.
Log4jService
public Log4jService ( URL url )
No description provided.
Parameters
TypeNameDescription
URL url The configuration URL.
Wiki javadoc Use textile entry format.
Add your comments here.
Log4jService
public Log4jService ( String url )
No description provided.
Parameters
TypeNameDescription
String url The configuration URL.
Exceptions
MalformedURLException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
Log4jService
public Log4jService ( String url, int refreshPeriod )
No description provided.
Parameters
TypeNameDescription
String url The configuration URL.
int refreshPeriod The refreshPeriod in seconds to wait between each check.
Exceptions
MalformedURLException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
Log4jService
public Log4jService ( URL url, int refreshPeriod )
No description provided.
Parameters
TypeNameDescription
URL url The configuration URL.
int refreshPeriod The refreshPeriod in seconds to wait between each check.
Wiki javadoc Use textile entry format.
Add your comments here.
createService
protected void createService ( )
throws
No description provided.
Overrides method in ServiceMBeanSupport
Returns void No description provided.
Exceptions
Exception No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
emitReconfigureNotification
protected void emitReconfigureNotification ( )
No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getCatchSystemErr
public boolean getCatchSystemErr ( )
Get the catch System.err flag.
Implements method in Log4jServiceMBean
Wiki javadoc Use textile entry format.
Add your comments here.
getCatchSystemOut
public boolean getCatchSystemOut ( )
Get the catch System.out flag.
Implements method in Log4jServiceMBean
Wiki javadoc Use textile entry format.
Add your comments here.
getConfigurationURL
public URL getConfigurationURL ( )
Get the Log4j configuration URL.
Implements method in Log4jServiceMBean
Wiki javadoc Use textile entry format.
Add your comments here.
getLog4jQuietMode
public boolean getLog4jQuietMode ( )
Get the org.apache.log4j.helpers.LogLog.setQuietMode flag
Implements method in Log4jServiceMBean
Wiki javadoc Use textile entry format.
Add your comments here.
getLoggerLevel
public String getLoggerLevel ( String name )
Gets the level of the logger of the give name.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
String name The name of the logger to inspect.
Wiki javadoc Use textile entry format.
Add your comments here.
getObjectName
protected ObjectName getObjectName ( MBeanServer server, ObjectName name )
No description provided.
Overrides method in ServiceMBeanSupport
Parameters
TypeNameDescription
MBeanServer server No description provided.
ObjectName name No description provided.
Exceptions
MalformedObjectNameException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getRefreshPeriod
public int getRefreshPeriod ( )
Get the refresh period.
Implements method in Log4jServiceMBean
Wiki javadoc Use textile entry format.
Add your comments here.
reconfigure
public void reconfigure ( )
throws
Force the logging system to reconfigure.
Implements method in Log4jServiceMBean
Returns void No description provided.
Exceptions
IOException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
reconfigure
public void reconfigure ( String url )
Hack to reconfigure and change the URL. This is needed until we have a JMX HTML Adapter that can use PropertyEditor to coerce.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
String url The new configuration url
Returns void No description provided.
Exceptions
IOException No description provided.
MalformedURLException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setCatchSystemErr
public void setCatchSystemErr ( boolean flag )
Set the catch System.err flag.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
boolean flag True to enable, false to disable.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setCatchSystemOut
public void setCatchSystemOut ( boolean flag )
Set the catch System.out flag.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
boolean flag True to enable, false to disable.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setConfigurationURL
public void setConfigurationURL ( URL url )
Set the Log4j configuration URL.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
URL url No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setLog4jQuietMode
public void setLog4jQuietMode ( boolean flag )
Set the org.apache.log4j.helpers.LogLog.setQuietMode flag
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
boolean flag No description provided.
Returns void True if enabled, false if disabled.
Wiki javadoc Use textile entry format.
Add your comments here.
setLoggerLevel
public void setLoggerLevel ( String name, String levelName )
Sets the level for a logger of the give name.

Values are trimmed before used.

Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
String name The name of the logger to change level
String levelName The name of the level to change the logger to.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setLoggerLevels
public void setLoggerLevels ( String list, String levelName )
Sets the levels of each logger specified by the given comma seperated list of logger names.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
String list A comma seperated list of logger names.
String levelName The name of the level to change the logger to.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setRefreshPeriod
public void setRefreshPeriod ( int refreshPeriod )
Set the refresh period.
Implements method in Log4jServiceMBean
Parameters
TypeNameDescription
int refreshPeriod No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
startService
protected void startService ( )
throws
No description provided.
Overrides method in ServiceMBeanSupport
Returns void No description provided.
Exceptions
Exception No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
stopService
protected void stopService ( )
throws
No description provided.
Overrides method in ServiceMBeanSupport
Returns void No description provided.
Exceptions
Exception No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.