Troubleshooting
Problem
This document provides instructions for using the dynamic tracing capabilities of the IBM Toolbox for Java.
Resolving The Problem
Sometimes tracing needs to be dynamically started and stopped without requiring the JVM be restarted.
IBM Toolbox for Java now has the ability to start a monitor thread that listens on a TCP socket for changes to the current trace settings. This behavior is controlled with two JVM properties:
1.
This property is set to either true or false. If true, a thread is started to listen for tracing behavior changes on a TCP socket.
2.
This property determines what port the monitor thread listens on. The default port is 55555. If you do not want to use the default port or it is already in use, set it to an available port on the platform where the JVM is running.
IBM Toolbox for Java now has the ability to start a monitor thread that listens on a TCP socket for changes to the current trace settings. This behavior is controlled with two JVM properties:
1.
com.ibm.as400.access.Trace.monitor
This property is set to either true or false. If true, a thread is started to listen for tracing behavior changes on a TCP socket.
2.
com.ibm.as400.access.Trace.monitorPort
This property determines what port the monitor thread listens on. The default port is 55555. If you do not want to use the default port or it is already in use, set it to an available port on the platform where the JVM is running.
Note: Only one JVM per machine can use the same port number. If multiple JVMs are running in the same machine, this property must be used to ensure each monitor thread is assigned an appropriate port.
Starting the Monitor
To start the monitor, the monitor property must be set to true. Optionally, the monitorPort property can be turned on to determine what port the monitor listens on. As an example, suppose the program to be traced is a stand-alone Java program started by using the Java command. An example command string to start this monitor would be as follows:
Starting the Monitor
To start the monitor, the monitor property must be set to true. Optionally, the monitorPort property can be turned on to determine what port the monitor listens on. As an example, suppose the program to be traced is a stand-alone Java program started by using the Java command. An example command string to start this monitor would be as follows:
java -Dcom.ibm.as400.access.Trace.monitor=true -Dcom.ibm.as400.access.Trace.monitorPort=##### MyJavaProgram
##### = Port number to listen on.
For more examples of how to pass an IBM Toolbox for Java JVM property to a Java program, see The All-In-One Toolbox Tracing Guide
The trace monitor is started when the IBM Toolbox for Java classes are touched in the JVM.
For more examples of how to pass an IBM Toolbox for Java JVM property to a Java program, see The All-In-One Toolbox Tracing Guide
The trace monitor is started when the IBM Toolbox for Java classes are touched in the JVM.
Verify the monitor is listening using NETSTAT *CNN and sub-setting the connection list with <F15>. Set the 3rd parameter to the monitorPort # used. For example:
Local port range:
Lower value . . . . . . . . 55555
Upper value . . . . . . . . *ONLY
Sending Commands to the Monitor
Once the monitor is started, commands can be sent to the monitor by using the built-in functions of the Trace class. Commands can be sent from any machine that has a JVM and jt400.jar in its CLASSPATH environment variable. The format of the command is as follows:
java com.ibm.as400.access.Trace [Host] [Port] [Trace property]
Host = The name or IP address of the machine hosting the monitor thread.
Port = The port that the monitor thread is listening on.
Trace property = The trace property to be changed, followed by an equals sign ('=') and then the value to set. Multiple properties can be specified. The monitor is listening for changes to two properties:
com.ibm.as400.access.Trace.category
com.ibm.as400.access.Trace.file
As an example, suppose the command is being run on the same machine where the monitor is listening, that it was started with the default port of 55555, and tracing needs to be turned on. The commands to start the trace:
java com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.file=/tmp/ToolboxTrace.txt
java com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.category=all
Only one property can be changed per call to the "Trace" object.
If the jt400.jar file isn't in the default class path, you would need to specify it as in the class path parameter for the Java command, for example:
If the jt400.jar file isn't in the default class path, you would need to specify it as in the class path parameter for the Java command, for example:
java -cp /qibm/proddata/http/public/jt400/lib/jt400.jar com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.file=/tmp/ToolboxTrace.txt
More Examples
Following are a list of some of the things that can be done with dynamic tracing.
Start the trace monitor while also starting the built-in jdbcClient application:
java -Dcom.ibm.as400.access.Trace.monitor=true -Dcom.ibm.as400.access.Trace.monitorPort=55555 com.ibm.as400.access.jdbcClient.Main jdbc:as400:localhost
Turn on "all" tracing:
java com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.category=all
Turn off tracing:
java com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.category=none
Change trace file path:
Redirect tracing to standard out:
java com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.file=/tmp/ToolboxTrace.txt
Redirect tracing to standard out:
java com.ibm.as400.access.Trace 127.0.0.1 55555 com.ibm.as400.access.Trace.file=
Related Information
[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CbKAAU","label":"Data Access->IBM i Toolbox for Java"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]
Historical Number
557749714
Was this topic helpful?
Document Information
Modified date:
11 January 2022
UID
nas8N1012340