bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

B2B Log

Writing to the Log

The following sections describe how to write messages to the B2B integration log:

- About the Log

- Writing Messages to the Log

About the Log

The B2B engine uses the Logging API to write error, warning, and information messages to a log file.

Log Files

Logged messages are written to the following locations:

- WebLogic Integration system log file (b2b.log) and the WebLogic Integration B2B Console (if it is running)

- WebLogic Server log file (weblogic.log) and the WebLogic Server Administration Console (if it is running)

The b2b.log system log file is created automatically when WebLogic Integration starts up. The size of this file is limited to 1MB. When this maximum is exceeded, the file is renamed with a numeric label (such as b2b1.log) and a new empty file is created.

Logging API

The com.bea.eci.logging package contains the Logging API, which consists of the classes described in the following table.

Table 1-1 Logging API

Name | Description
--- | ---
Log | Defines severity levels for log messages.
UserLog | Represents a user log. Provides access to the log for users. The user log is defined as a user log output stream (with a <user> tag) in the system log.

For detailed information about these classes, see the BEA WebLogic Integration Javadoc.

Severity Levels

The Log class defines the severity levels described in the following table.

Table 1-2 Severity Levels Defined in Log Class

Level | Severity | Indicates an occurrence of . . .
--- | --- | ---
1 | FATAL | A fatal error; a system component failed abnormally due to the exception that was detected.
2 | ERROR | A critical error; system stability is affected.
3 | WARNING | A minor exception; normal operation or system stability may not be affected.
4 | INFO | No exception or failure; indicates only a message reporting normal operations, not exception conditions. An example of such a message is logging the successful startup of the WebLogic Integration B2B Console.

Writing Messages to the Log

WebLogic Integration applications can write messages to the log using the log method in the UserLog class. The log method records a message in the user log and does one of the following:

- Specifies the level of severity as FATAL, ERROR, WARNING, or INFO.

- Does not specify the level of severity, which then defaults to INFO.

In addition, applications can access the print stream to the user log using UserLog.out.

Importing the Logging Package

To write to the log, WebLogic Integration applications must import the com.bea.eci.logging package, as shown in the following listing.

Listing 1-1 Importing the com.bea.eci.logging Package

>     import com.bea.eci.logging.*;

Writing a Log Message with an INFO Severity Level

To write a log message with an INFO severity level, an application can use the following version of the log method:

>     static void log(java.lang.String userMsg)

In the preceding line, userMsg is the message text to be logged.

When you use this version of the log method, the severity in the log defaults to INFO. The following listing shows how to write a log message with an INFO severity level.

Listing 1-2 Writing an INFO Message to the Log

>     private static void debug(String msg){
>         if (DEBUG)
>           UserLog.log("***Partner1Servlet: "+msg);
>     }

Writing a Message with a Specific Severity Level

To write a log message with a specific severity level, an application uses the following version of the log method:

>     static void log(int severity, java.lang.String userMsg)

In the preceding line:

- severity is the severity level (FATAL, ERROR, WARNING, or INFO).

- userMsg is the message text to be logged.

The following listing shows how to write a log message with a WARNING severity level.

Listing 1-3 Writing a WARNING Message to the Log

>     private static void debug(String msg){
>           if (DEBUG)
>                 UserLog.log(Log.WARNING, msg);
>     }

>     try {
>           }catch(Exception e){
>                 debug("Partner1 exception errors");
>                 e.printStackTrace(UserLog.out);
>     }