Capturing Trace Logs on Pramati Server

Often in our application we need to analyse in detail the cause for a response (usually undesired) from a J2EE application server. Well, needless to say that the details can be best analysed by the Guys who implemented that server code, however such logs can definitely provide a vivid picture of the whole processing cycle.

On Pramati Server such a detailed log is called Trace Log. Best part being that the same can be enabled or disabled in runtime. The output can be printed to a console or saved to a file for future review. The trace options, like component for which trace is enabled, Logging severity level, file logging or console print etc., can be specified dynamically or can be read from a properties file.

A generic Trace Properteis file : Say server_trace.props: can contain:

handler.pramatihandler.contexttype.packages=.,true
handlers=pramatihandler
loglevel=debug
asynch=true
handler.pramatihandler.details=servertrace.log
handler.pramatihandler.type=file

This indicates that with these properties loaded, the trace logs shall be logged with minimum of Debug level, into a file named servertrace.log (in the logs directory of the node) for all packages (like web, ejb, jms ….).

With Pramati Server Running on a machine, you might most likely to have the j2eeadmin@<node-name> prompt available to you.

To Start a detailed logging of the server side activities, you can load trace by executing the following command at the above prompt. For example:

trace load server_trace.props

The server_trace.props file should be located in the <server-install>/server/bin directory in this case. If trace is loaded successfully, the following message should appear on the console

Successfully loaded trace properties

Now, with trace loaded we can carryout the task for which the detailed trace log is needed. This can involve in accessing a web page or invoking a java client etc. As we carry out the activity, servers activity logs shall be populated in the servertrace.log.* files in <server-install>/server/nodes/<node-name>/logs directory.

Once we are done with our issue replication, we can unload trace by executing the following command:

trace unload

A confirmation message shall appear on the console that trace has been unloaded successfully.

Successfully unloaded trace properties

Now the servertrace.log.* files can be collected and reviewed for analysis.

Interactive Loading of Trace:

Trace can also be loaded interactively by executing the following command:

trace load

and interactively the required options can be provided. For example:

j2eeadmin@default>  – asynch [true] #true

j2eeadmin@default>  – Logging Level [info] #debug

j2eeadmin@default>  – Type of logging [console] #file

j2eeadmin@default>  – Output File Name * #server_trace.log

j2eeadmin@default>  – Target Packages [all] #all

j2eeadmin@default>  – Save File Name #server_trace.props

Such logs can be unloaded by similar command (trace unload).

Using Remote Shell to Load Trace:

If server j2eeadmin@<node-name> prompt is not available, remote shell can be used to load and unload trace as well. Information on connecting to server using remote shell can be located at http://server.pramati.com/blog/2009/12/14/the-pramati-server-remote-shell/

Note: Just make sure that the server_trace.props file, if used for loading trace, should be placed in the <server-install>/server/bin directory of the server installation, from where the remoteshell script is being invoked.

To collect Trace for any Issue:

The steps to be followed are

[Load Trace]- [Replicate the issue]-[Unload Trace]-[Collect Trace logs]- [Analyse]

Do remember to unload trace, as the trace logs are populated very fast and can consume lot of system resoureces if left loaded for long time.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)