5.3.9 Enabling tracing for WebSphere components
This section illustrates how to enable tracing for a server process using the setAttribute command on the TraceService MBean.
In a ND environment, there are multiple server processes and therefore multiple TraceService MBeans. Example 5-40 shows how to use queryNames to list the TraceService MBeans.
Example 5-40 List of TraceService MBeans
wsadmin>print AdminControl.queryNames('type=TraceService,*') WebSphere:name=TraceService,process=dmgr,platform=proxy,node=kcgg1f3CellManager01,version=6.1.0.0,type=TraceService,mbeanIdentifier=cells/kcgg1f3Cell01/nodes/kcgg1f3CellManager01/servers/dmgr/server.xml#TraceService_1,cell=kcgg1f3Cell01,spec=1.0 WebSphere:name=TraceService,process=nodeagent,platform=proxy,node=kcgg1f3Node01,version=6.1.0.0,type=TraceService,mbeanIdentifier=cells/kcgg1f3Cell01/nodes/kcgg1f3Node01/servers/nodeagent/server.xml#TraceService_1120677326772,cell=kcgg1f3Cell01,spec=1.0 WebSphere:name=TraceService,process=server2,platform=proxy,node=kcgg1f3Node01,version=6.1.0.0,type=TraceService,mbeanIdentifier=cells/kcgg1f3Cell01/nodes/kcgg1f3Node01/servers/server2/server.xml#TraceService_1154007376682,cell=kcgg1f3Cell01,spec=1.0
To start tracing for a server, locate the TraceService MBean for the server process using the completeObject command. Example 5-41 shows how to do this using a variable named ts, which is set to the value of the tracing service MBean. In the second step, the setAttribute command is used to enable the tracing.
Example 5-41 Enable tracing using TraceService mbean
wsadmin>ts = AdminControl.completeObjectName('type=TraceService,process=server1,*')wsadmin>AdminControl.setAttribute(ts,'traceSpecification','com.ibm.ejs.*=all')
The SystemOut.log file for the Server reflects this new trace specification, as the TraceService has logged this statement:
TRAS0018I: The trace state has changed. The new trace state is *=info:com.ibm.ejs.*=allNote that setting trace level with use of the AdminControl object only changes the current trace specification of the TraceService. The specification is not stored to the WebSphere configuration repository. To change the configuration permanently, use the modify command of the AdminConfig object to change the traceSpecification attribute of the TraceService configuration object.