WAS v8.5 > Troubleshoot > Use Cross Component TraceConfigure XCT with wsadmin scripting
We can configure Cross-Component Trace (XCT) using wsadmin.sh. Use the examples in this topic as a guide to build our own wsadmin scripts.
XCT annotates the logs so that log entries related to a request that is serviced by more than one thread, process, or even server are identified as belonging to the same unit of work. We can configure XCT using the dmgr console, or using wsadmin.sh. The examples in this topic show how to configure XCT using wsadmin. If you complete this task using the deployment manager, then we might need to synchronize the node agent on the target node and restart the server before configuration changes take effect.
- Use the AdminConfig object to configure XCT.
Changes you make using the AdminConfig object take effect the next time you start the server.
- Enable XCT for the server.
By default, XCT is disabled for the server. The following example shows how to enable XCT for the server when the server is using HPEL log and trace mode. Specify RASLoggingService instead of HighPerformanceExtensibleLogging when the server is using basic log and trace mode. Specify false instead of true to disable XCT.
# get rid of existing property if already present configId = AdminConfig.getid("/Cell:myCell/Node:myNode /Server:myServer/HighPerformanceExtensibleLogging: /Property:com.ibm.websphere.logging.enableCorrelation")if (len(configId) > 0): AdminConfig.remove(configId) # add new property LoggingService = AdminConfig.getid("/Cell:myCell/Node:myNode /Server:myServer/HighPerformanceExtensibleLogging:/") AdminConfig.create("Property", LoggingService, [["name", "com.ibm.websphere.logging.enableCorrelation"],["value", "true"]]) AdminConfig.save()
- Change the log setting for XCT .
By default, the XCT log setting includes request IDs in log and trace files. The following example shows how to make XCT both include request IDs in log and trace files and log XCT log records. Specify REQUEST ID instead of LOG to make XCT only include request IDs in log and trace files. Specify DATA_SNAPSHOT instead of LOG to make XCT include request IDs in log and trace files, log XCT log records, and capture data snapshots. Specify RASLoggingService instead of HighPerformanceExtensibleLogging when the server is using basic log and trace mode.
# get rid of existing property if already present configId = AdminConfig.getid("/Cell:myCell/Node:myNode /Server:myServer/HighPerformanceExtensibleLogging:/Property:com.ibm.websphere .logging.correlationLevel") if (len(configId) > 0): AdminConfig.remove(configId) # add new property LoggingService = AdminConfig.getid("/Cell:myCell/Node:myNode Server:myServer/HighPerformanceExtensibleLogging:/") AdminConfig.create("Property", LoggingService, [["name", "com.ibm.websphere.logging.correlationLevel"],["value", "LOG"]]) AdminConfig.save()Best practice: Enable XCT to include request IDs in log and trace files when we want to see which log and trace entries, in all threads and application server processes, are related to the same request. Request IDs are only recorded when using HPEL log and trace mode and can be seen or used for filtering using the logViewer command..
Best practice: Enable XCT to create correlation log records when we want to log how requests branch between threads and processes, and see extra information about each request. Enabling XCT to create correlation log records might have a significant performance impact on the system, so is best suited to test and development environments.
Best practice: Enable XCT to capture data snapshots when we want to store entire request and response bodies to the file system. Enabling XCT to capture data snapshots might have a significant performance impact on the system, so is best suited to test and development environments. XCT captures data snapshots for message requests and responses handled by the SIBus.
Data snapshots are captured and written to the $SERVER_LOG_ROOT/snapdata directory. The application server does not automatically clean up files from this directory. You will need to delete the files from this directory periodically when data snapshot capturing is enabled. Data snapshots store entire request and response contents and may include sensitive information. This option might not be appropriate for use in production environments.
- Use the AdminControl object to configure XCT. Changes you make using the AdminControl object take effect immediately.
- Enable XCT for the server.
By default, XCT is disabled for the server. The following example shows how to enable XCT for the server when the server is using HPEL log and trace mode. Ensure the server is running and specify RasLoggingService instead of HPELControlService when the server is using basic log and trace mode. Specify false instead of true to disable XCT.
LoggingMBean = AdminControl.queryNames('cell=myCell,node=myNode, type=HPELControlService,process=myServer,*') AdminControl.setAttribute(LoggingMBean, "correlationEnabled", "true")
- Change the log setting for XCT .
By default, the XCT log setting includes request IDs in log and trace files. The following example shows how to make XCT both include request IDs in log and trace files and log XCT log records. Specify REQUEST ID instead of LOG to make XCT only include request IDs in log and trace files. Specify DATA_SNAPSHOT instead of LOG to make XCT include request IDs in log and trace files, log XCT log records, and capture data snapshots. Ensure the server is running and specify RasLoggingService instead of HPELControlService when the server is using basic log and trace mode.
LoggingMBean = AdminControl.queryNames('cell=myCell,node=myNode,type=HPELControlService,process=myServer,*') AdminControl.setAttribute(LoggingMBean, "xctLevel", "LOG")Best practice: Enable XCT to include request IDs in log and trace files when we want to see which log and trace entries, in all threads and application server processes, are related to the same request. Request IDs are only recorded when using HPEL log and trace mode and can be seen or used for filtering using the logViewer command..
Best practice: Enable XCT to create correlation log records when we want to log how requests branch between threads and processes, and see extra information about each request. Enabling XCT to create correlation log records might have a significant performance impact on the system, so is best suited to test and development environments.
Best practice: Enable XCT to capture data snapshots when we want to store entire request and response bodies to the file system. Enabling XCT to capture data snapshots might have a significant performance impact on the system, so is best suited to test and development environments. XCT captures data snapshots for message requests and responses handled by the SIBus.
Data snapshots are captured and written to the $SERVER_LOG_ROOT/snapdata directory. The application server does not automatically clean up files from this directory. You will need to delete the files from this directory periodically when data snapshot capturing is enabled. Data snapshots store entire request and response contents and may include sensitive information. This option might not be appropriate for use in production environments.
Results
XCT is now configured. If you made changes with the AdminConfig command, restart the server to make the changes take effect.
Related concepts:
XCT
Related
Use the wsadmin scripting AdminConfig object for scripted administration
Reference:
LogViewer command-line tool