FileDocCategorySizeDatePackage
TraceManager.javaAPI DocJava SE 6 API10043Tue Jun 10 00:22:10 BST 2008com.sun.jmx.trace

TraceManager

public class TraceManager extends Object implements TraceDestination
Provides an implementation of the {@link com.sun.jmx.trace.TraceDestination} interface which uses the J2SE logging API.

Note that this implementation can be used only with J2SE version 1.4 or higher.

All {@link Logger}s are contained in the javax.management namespace, which corresponds to the name of the root package hosting all public JMX interfaces. For each log type defined in {@link TraceTags}, we use a dedicated {@link Logger} with the same name under javax.management.

The table below shows the list of {@link Logger} objects used in this implementation and their corresponding category of activity.

Logger Name JMX log type Information logged
javax.management.mbeanserver {@link TraceTags#INFO_MBEANSERVER} Information about the MBean Server
com.sun.jmx.snmp.daemon {@link TraceTags#INFO_ADAPTOR_SNMP} Information about the SNMP Adaptor
com.sun.jmx.snmp {@link TraceTags#INFO_SNMP} Information about SNMP
javax.management.mlet {@link TraceTags#INFO_MLET} Information from an MLet service
javax.management.monitor {@link TraceTags#INFO_MONITOR} Information from a monitor
javax.management.timer {@link TraceTags#INFO_TIMER} Information from a timer
javax.management.notification {@link TraceTags#INFO_NOTIFICATION} Information from the notification mechanism
javax.management.relation {@link TraceTags#INFO_RELATION} Information from the Relation Service
javax.management.modelmbean {@link TraceTags#INFO_MODELMBEAN} Information from the Model MBean components
javax.management.misc {@link TraceTags#INFO_MISC} Information sent from any other class


The mapping for the JMX log levels is the following:

JMX log level J2SE logging API log level
{@link TraceTags#LEVEL_DEBUG}
{@link Level#FINEST}
{@link TraceTags#LEVEL_TRACE}
{@link Level#FINER}
{@link TraceTags#LEVEL_ERROR}
{@link Level#SEVERE}
since
1.5
since.unbundled
JMX RI 1.2

Fields Summary
Constructors Summary
Methods Summary
voidfine(java.lang.String loggerName, java.lang.String msg)
Logs a fine message. This is equivalent to Logger.getLogger(loggerName).fine(msg);

since.unbundled
JMX RI 1.2.1

	Logger.getLogger(loggerName).fine(msg);	
    
private static java.util.logging.LevelgetLevel(int level)
Returns the {@link Level} corresponding to the integer value passed as argument. This value is assumed to be part of the log levels defined by class {@link TraceTags}.

return
  • {@link Level#FINEST} if value is {@link TraceTags#LEVEL_DEBUG}
  • {@link Level#FINER} if value is {@link TraceTags#LEVEL_TRACE}
  • {@link Level#SEVERE} if value is {@link TraceTags#LEVEL_ERROR}
  • null otherwise

    switch(level)
    {
    case TraceTags.LEVEL_DEBUG:
      return Level.FINEST;
    case TraceTags.LEVEL_TRACE:
      return Level.FINER;
    case TraceTags.LEVEL_ERROR:
      return Level.SEVERE;
    default:
      return null;
    }
  
private static java.util.logging.LoggergetLogger(int type)
Returns the {@link Logger} corresponding to the integer value passed as argument. This value is assumed to be part of the log types defined by class {@link TraceTags}.

return
  • Logger.getLogger("javax.management.mbeanserver")if value is {@link TraceTags#INFO_MBEANSERVER}
  • Logger.getLogger("javax.management.mlet")if value is {@link TraceTags#INFO_MLET}
  • Logger.getLogger("javax.management.monitor")if value is {@link TraceTags#INFO_MONITOR}
  • Logger.getLogger("javax.management.timer")if value is {@link TraceTags#INFO_TIMER}
  • Logger.getLogger("javax.management.misc")if value is {@link TraceTags#INFO_MISC}
  • Logger.getLogger("javax.management.notification")if value is {@link TraceTags#INFO_NOTIFICATION}
  • Logger.getLogger("javax.management.relation")if value is {@link TraceTags#INFO_RELATION}
  • Logger.getLogger("javax.management.modelmbean")if value is {@link TraceTags#INFO_MODELMBEAN}
  • Logger.getLogger("com.sun.jmx.snmp.daemon")if value is {@link TraceTags#INFO_ADAPTOR_SNMP}
  • Logger.getLogger("com.sun.jmx.snmp")if value is {@link TraceTags#INFO_SNMP}
  • null otherwise

    switch(type)
    {
    case TraceTags.INFO_MBEANSERVER:
      return Logger.getLogger("javax.management.mbeanserver");
    case TraceTags.INFO_ADAPTOR_SNMP:
      return Logger.getLogger("com.sun.jmx.snmp.daemon");
    case TraceTags.INFO_SNMP:
      return Logger.getLogger("com.sun.jmx.snmp");
    case TraceTags.INFO_MLET:
      return Logger.getLogger("javax.management.mlet");
    case TraceTags.INFO_MONITOR:
      return Logger.getLogger("javax.management.monitor");
    case TraceTags.INFO_TIMER:
      return Logger.getLogger("javax.management.timer");
    case TraceTags.INFO_MISC:
      return Logger.getLogger("javax.management.misc");
    case TraceTags.INFO_NOTIFICATION:
      return Logger.getLogger("javax.management.notification");
    case TraceTags.INFO_RELATION:
      return Logger.getLogger("javax.management.relation");
    case TraceTags.INFO_MODELMBEAN:
      return Logger.getLogger("javax.management.modelmbean");
    default:
      return null;
    }
  
public booleanisSelected(int level, int type)

see
TraceDestination#isSelected

    Logger logger;
    Level  lvl;
    if (((logger = getLogger(type)) != null) &&
        ((lvl = getLevel(level)) != null))
    {
      return logger.isLoggable(lvl);
    }
    return false;
  
public voidreset()
Not implemented, as the control over log levels and output handler is deferred to the J2SE logging API.

see
TraceDestination#reset

    
  
public booleansend(int level, int type, java.lang.String className, java.lang.String methodName, java.lang.String info)
Note that the provided log type and log level have to be part of the enumerated values defined in class {@link TraceTags}. Otherwise, nothing is logged.

see
TraceDestination#send(int, int, String, String, String)

    if (isSelected(level, type))
    {
      getLogger(type).logp(getLevel(level), className, methodName, info);
      return true;
    }
    return false;
  
public booleansend(int level, int type, java.lang.String className, java.lang.String methodName, java.lang.Throwable exception)
Note that the provided log type and log level have to be part of the enumerated values defined in class {@link TraceTags}. Otherwise, nothing is logged.

see
TraceDestination#send(int, int, String, String, Throwable)

      if (isSelected(level, type)) {
	  getLogger(type).log(getLevel(level), 
		  className + ": Exception occurred in " + methodName , 
		  exception);
	  return true;
  }
      return false;
  
voidwarning(java.lang.String loggerName, java.lang.String msg)
Logs a warning message. This is equivalent to Logger.getLogger(loggerName).warning(msg);

since.unbundled
JMX RI 1.2.1

	Logger.getLogger(loggerName).warning(msg);