Java Dynamic Management Kit 5.0 Tools Reference

Receiving Trace and Debug Information

The com.sun.jdmk.TraceManager class uses the notification mechanism to distribute the information. You must add a notification listener to receive information (see example Example 4–1). There are two ways to receive trace information:


Example 4–1 Creating a Notification Listener

// Create a listener and save all info to the file /tmp/trace 
TraceListener listener = new TraceListener("/tmp/trace"); 


Example 4–2 Creating a Trace Filter

// create a trace filter with LEVEL_DEBUG and INFO_ALL/
TraceFilter filter = new TraceFilter(Trace.LEVEL_DEBUG, Trace.INFO_ALL);


Example 4–3 Adding the Notification Listener to the class

// add the listener to the class Trace/
TraceManager.addNotificationListener(listener, filter, null);