TraceManagerpublic class TraceManager extends Object implements TraceDestinationProvides 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} |
|
Methods Summary |
---|
void | fine(java.lang.String loggerName, java.lang.String msg)Logs a fine message.
This is equivalent to
Logger.getLogger(loggerName).fine(msg);
Logger.getLogger(loggerName).fine(msg);
| private static java.util.logging.Level | getLevel(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}.
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.Logger | getLogger(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}.
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 boolean | isSelected(int level, int type)
Logger logger;
Level lvl;
if (((logger = getLogger(type)) != null) &&
((lvl = getLevel(level)) != null))
{
return logger.isLoggable(lvl);
}
return false;
| public void | reset()Not implemented, as the control over log levels and output handler is
deferred to the J2SE logging API.
| public boolean | send(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.
if (isSelected(level, type))
{
getLogger(type).logp(getLevel(level), className, methodName, info);
return true;
}
return false;
| public boolean | send(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.
if (isSelected(level, type)) {
getLogger(type).log(getLevel(level),
className + ": Exception occurred in " + methodName ,
exception);
return true;
}
return false;
| void | warning(java.lang.String loggerName, java.lang.String msg)Logs a warning message.
This is equivalent to
Logger.getLogger(loggerName).warning(msg);
Logger.getLogger(loggerName).warning(msg);
|
|