Enabling Logging for Applications 
There are two main steps in enabling logging for your application:
Identify a source code area (for example, a class Node) and represent it with a Location object:
Location loc = Location.getLocation("<package>.Node");
Input a trace message with specified severity:
loc.entering(methodname);
loc.debugT(methodname, message);
loc.fatalT(methodname, message);
A very basic sample code shows these two steps:
Syntax
package com.sap.fooPackage;
import com.sap.tc.logging.*;
public class Node {
private static final Location loc =
Location.getLocation("com.sap.fooPackage.Node");
public void announce(Object o) {
String method = "announce(java.lang.Object)";
loc.entering(method);
try {
// do something...
loc.debugT(method, "Connecting to …");
} catch (Exception e) {
loc.fatalT(
method,
"Error processing object {0}",
new Object[] { o });
}
loc.exiting();
}
}The output is redirected to a ConsoleLog (terminal).
The output, formatted with TraceFormatter (default formatter for ConsoleLog), looks like this:
May 3, 2007 6:54:18 PM com.sap.fooPackage.Node.announce [main] Path: Entering method May 3, 2001 6:54:18 PM com.sap.fooPackage.Node.announce [main] Debug: Connecting to …. May 3, 2001 6:54:18 PM com.sap.fooPackage.Node.announce [main] Path: Exiting method |