Show TOC Start of Content Area

Background documentation Enabling Logging for Applications  Locate the document in its SAP Library structure

Logging Steps

There are mainly four steps in enabling logging for your application.

...

       1.      Identify a source code area (for example, a class Node) and represent it with a Location object:

Location loc = Location.getLocation("<package>.Node"); 

       2.      Instrument 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:

This graphic is explained in the accompanying text

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, 2001 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

 

 

More Information

Appendix A: Severity Levels

Enable Output Messages

 

End of Content Area