Tracing

Topics:

Tracing is the key to diagnosing problems and thus to application reliability. iWay Service Manager provides a full complement of tracing services, oriented to diagnostic analysis of the running system.

Experience teaches that tracing can also be a major source of performance degradation. This comes primarily from the string processing needed to form meaningful trace messages. Before you build a message that has several parts, check the following method to determine if the trace message is emitted

logger.isTraceLevelEnabled()

where:

TraceLevel

Is the specified trace level.

If the trace message is not emitted, then there is little purpose to construct it. Too much tracing is as bad as too little. Messages with several values to assist the debugger are easier to work with than several small messages that may get separated on a trace display.

Line feeds and tabs can be included in messages to make them easier to understand. Never start or end a trace message with a tab or line feed.

Tracing in iSM-level servers has been changed from prior releases, although exits written to the older trace() method calls will continue to function. In iSM, trace calls mirror the calls used in other familiar tracing systems, although with distinctions.

In most Java applications, trace levels are hierarchical. Any specific level sets all "lower" levels. In a server, this is expected to run for extended periods of time. The plethora of trace messages that would be generated in such a case when attempting to isolate problems could be enormous. To this end, iWay uses a mechanism based on trace categories. As an example, setting the PARSE category on traces only parsing operations and does not imply that all debugging levels will be consequently set.

When exits are entered, the trace has been enabled for the desired settings. All exits extend a standard base, and this base is a logger. As a result, you do not need to specifically refer to a logger when making trace calls. The protected field logger is available should you wish to use it.

debug("this is a debug message")

and

logger.debug("this is a debug message")

are equivalent.

When coding a listener or emitter, you must specifically refer to the logger in your calls, as these objects do not themselves act as loggers.

All levels provide two calls:

Call

Description

level(String)

Issues a trace message at that level in the context of the logger.

isLevelEnabled

Returns true if the trace level is enabled.

For example, debug(String) and isDebugEnabled() are defined for the debug level.

At the error level, the additional call is provided:

Call

Description

error(String,Throwable)

Traces an error message with a stack trace

Trace levels supported are:

In addition to control using the consoles, any trace level can be set on or off using the command window when the server is running as an executable process. The command

set level on|off

where the level specifies the level to be controlled, will turn on or off tracing.

Use set display to see what levels are enabled.

Interacting With Log4J

Some components interact with externally-developed components that use the Log4J tracing system. The iWay server can route such traces to its own logs, using a Log4J configuration file as described in Interacting With Log4J. Log4J is classed by iWay as an external log system, and is turned on in the server by setting the external level.