The com.sun.jdmk.Trace 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:
adding a notification listener with a filter in the code. It is possible to have more than one notification listener but with different filters. With TraceFilter, you can specify the type and level of information you wish to receive. See Example 4-3 and Example 4-2.
specifying system properties in the command to start the Java interpreter when you run a class. In this case, the code of the class must include a call to method Trace.parse.TraceProperties();.
// Create a listener and save all info to the file /tmp/traceInfo/ TraceListener listener = new TraceListener("/tmp/trace");
// add the listener to the class Trace/ Trace.addNotificationListener(listener, filter, null);
You can also use the class TraceListener to save trace information to a file.
// create a trace filter with LEVEL_DEBUG and INFO_ALL/ TraceFilter filter = new TraceFilter(Trace.LEVEL_DEBUG, Trace.INFO_ALL);