Article : Package com.sap.ip.bi.sdk.util

Package com.sap.ip.bi.sdk.util


Provides functionality for configuring logging and tracing, and JARM (monitoring) functionality, via properties files.
See:
  Description
Class Summary
BILoggingSetup Configuration class for logging and tracing.
BILoggingSetup.Category Simple typesafe enumeration for logging and tracing categories to ensure uniform use of categories within the BI Java SDK.
BISatCheck An implementation of ISatCheck (JARM-SAT adapter) used by SAP's JARM (Java Application Responsetime Measurement) Log Adapter via SatCheckHandler.registerSatCheck to allow the Log Adapter to check whether trace data has to be collected (BISatCheck.isTraceOn(String,String) or BISatCheck.isTraceOn(String,String,long,int)).  
 

Package com.sap.ip.bi.sdk.util Description

Provides functionality for configuring logging and tracing, and JARM (monitoring) functionality, via properties files. Both the logging and tracing and the monitoring functionality are provided for in a managed environment by the Web Application Server, but using local properties files you can configure this functionality for non-managed environments as well. This package documentation explains how to do so in the following sections:

â– Configuring Logging and Tracing in a Non-Managed Environment
â– Create a Log Settings File
â– Initialize the Log Settings File
â– Configuring JARM in a Non-Managed Environment
â– Create a Properties File
â– Initialize the Properties File
â– Interpret the Trace File
â– Additional Information
Configuring Logging and Tracing in a Non-Managed Environment
SAP's Web Application Server provides visual configuration of its logging and tracing functionality through the LogConfigurator service for applications deployed into its managed environment.

If you are working in a non-managed environment, logging and tracing is configured by default to report all errors that occur on the BI Java SDK level and write them to a log file in the current Java source directory. You may use the SDK with the default log settings, or you may change the settings.

To change the default log settings in a non-managed environment, see the steps below.

Create a Log Settings File
Log settings are specified in a log settings properties file. If you want to change any of the default log settings, such as log directory or log severity, you do so by creating a new log settings file. The contents of the default log settings file are represented below. For information about how to manipulate these configuration settings, see the Logging API documentation in SAP's Online Help at:

http://help.sap.com/saphelp_nw04/helpdata/en/4A/C3953FF1353C17E10000000A114084/frameset.htm.


Default log settings file

# Log configuration for location-based logging for all BI Java SDK packages and sub-packages.
# Any class can override the severity by calling setSeverity explicitly on the location.


com.sap.ip.bi.sdk.severity =ERROR
com.sap.ip.bi.sdk.logs = log[FileLoc],log[ConsoleLoc]
log[FileLoc] = FileLog
log[FileLoc].desc = SDK Location Logging
log[FileLoc].pattern = BI_SDK_Trace.log
log[FileLoc].formatter = ListFormatter
log[ConsoleLoc]= ConsoleLog


# log configuration for category


/Application/BI.severity= WARNING
log[FileCat]= FileLog
log[FileCat].pattern= BI_SDK_Log.log
log[FileCat].desc = SDK Category Logging
log[FileCat].formatter = ListFormatter


#### Set up a ConsoleLog, with : 'ConsoleCat'
log[ConsoleCat]= ConsoleLog
/Application/BI.logs=  log[FileCat],log[ConsoleCat]

By default, these settings contain the configuration for the parent package: com.sap.ip.bi.sdk, and all child packages derive the same configuration. You can override them by creating separate properties files or by modifying your implementation using SAP's Logging API.

Initialize the Log Settings File
Then, to implement logging and tracing in your client application, call BILoggingSetup's setup(File) method during the application's initialization phase. Instantiate a file object with an absolute path for the log settings file, and use this file object as the parameter for the method. Refer to the example below:

Client code example

import java.io.File;
import com.sap.ip.bi.sdk.util.BILoggingSetup;

public class MyClass {

  // location object is needed to log trace data for logging/tracing

  private static final Location biLog =
  Location.getLocation(MyClass.class.getName());

  // empty constructor
  public MyClass() {
   
  // "filename" points to the project's current
  // directory (in Eclipse, this is the project's root directory).

  String filename = "BILoggingSetup.properties";
  try {
  //  BILoggingSetup.setup method is called to initialize the  
  //  log settings file
  BILoggingSetup.setup(new File(filename));
    // insert user code here ...
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
  public static void main(String[] args)
  {
  MyClass myClass = new MyClass();
   
  }
 }

If you choose to use any log settings other than the default, you must use this method before any occurrence of a logging call in your client code in order to initialize the log settings file. If any modification is needed, you can change the log settings file and execute the code again.

 

Configuring JARM in a Non-Managed Environment
SAP's JARM (Java Application Responsetime Measurement) provides functionality for monitoring and tracing the status of a Java system. The SAP Web Application Server provides JARM functionality for applications deployed into its managed environment through its ApplicationTracing service (on the JARM tab).

You can also use the JARM instrumentation when using the BI Java SDK in a non-managed environment. For example, you can use the SDK's JARM instrumentation to analyze the speed of an activity or method. In a non-managed environment, the tracing functionality is switched off by default. To begin writing JARM data to a trace file, you must follow the steps below.

Create a Properties File
Create a simple properties file with one line of text, as below:

SAT_TRACE_SWICH=ON

The SAT_TRACE_SWITCH property is off by default in the SDK (SAT_TRACE_SWICH=OFF). When you switch it on using a properties file as above, JARM writes trace data to a file.

Name this file BISatCheck.properites and place it in the location of your choice.

Initialize the Properties File
Next, you must initialize the properties file in your client application. To do this, call BISatCheck's setup(File) method during the application's initialization phase. Instantiate a file object with an absolute path for the properties file, and use this file object as the parameter for the method. Refer to the example below:

Client code example

import java.io.File;
import com.sap.ip.bi.sdk.util.BISatCheck;

public class MyClass {

  // empty constructor
  public MyClass() {
   
  // "filename" points to the project's current
  // directory (in Eclipse, this is the project's root directory)

  String filename = "BISatCheck.properties";
  try {
  //  BISatCheck.setup method is called to initialize the  
  //  properties file
  BISatCheck.setup(new File(filename));
    // insert user code here ...
  } catch (Exception e) {
  e.printStackTrace();
  }
   
  }
  public static void main(String[] args)
  {
  MyClass myClass = new MyClass();
   
  }
 }

Interpret the Trace File
Locate the JARM trace file and interpret it to find the execution times of various actions. The trace files are written to a log subdirectory which is created automatically in the project's current directory (in Eclipse, this is the project's root directory).

1.In the log directory, open the most recent trace file, sat.trc.* (where * is a number and depends on whether other applications have written SAP traces). This file is generated by running programs created with the SDK.
2.Search for the class name or name of the method you are interested in monitoring. If you wanted to find out how long it took to execute a query, for example, you would search for an entry with the method name "BIQuery:execute".
3.Find the seconds taken to execute the activity:
Look for groups of numbers separated by pound (#) signs which come after the name of the method (BIQuery:execute, in this example). An example of a portion of such a trace appears below:
#BI:SDK::com.sap.ip.bi.sdk.dac.olap.query.impl.BIQuery:execute(IBIQuery)#N/A#0#1070669316228#14571#0#-1#1# #N/A#N/A#
In the excerpt above, the third group of numbers separated by # signs is the execution time of the method in milliseconds. We have bold-faced the number for demonstration purposes only. This number tells you how long it took to execute a query. In this case, the query took 14.179 seconds to execute.

If you have the stand-alone Log Viewer, you may also use it to view the trace file more easily.

For Additional Information

â– SAP Logging API in the Web Application Server:
http://help.sap.com/saphelp_nw04/helpdata/en/4A/C3953FF1353C17E10000000A114084/frameset.htm
â– Viewing SAT Logs in the Web Application Server:
http://help.sap.com/sapdocu/Netweaver/webas/630/helpdata/EN/80/b2048cc1284b298e2971cb318bc946/frameset.htm