Trace script

 

+

Search Tips   |   Advanced Search

 

Sometimes we need to activate a trace level for a specific component (for example, com.ibm.ws.xd.placement.*=all) in order to reproduce and understand an error in our application.

We can do this through the Administrative Console or using a wsadmin script.

In this appendix we provide a script which will change the runtime trace level for a specific node and a particular component. The scripts reads the trace settings from a properties file. We can add new trace specifications to the properties file as we like.

The usage is:

wsadmin -f setServerTracing.jacl server_name node properties_file trace_spec_name

For example:

wsadmin -f setServerTracing.jacl node1 node1 TraceSpec.properties arfm_node

Trace Specification Name

Description

arfm_odr Autonomic Request Flow Manager on ODR
arfm_node Autonomic Request Flow Manager on Node
charting Dynamic charting - runtime topology
dcs Distribution and consistency services, reliable multicast messaging
dwlm Dynamic workload manager
grid Business grid
ham High availability manager
odc On demand configuration
operationalpolicy Service and health policies
placement Application placement controller
proxy ODR issues
reset Reset the trace level to the default of *=info
runtime Runtime charting issues
tcp TCP channel framework
tcpdcs Combination of TCP and DCS
vizcache Visualization engine cacheservice
webcontainer Web container

 

Trace level change script

setServerTracing.jacl

proc loadProperties {propFileName} {
    java::import java.io.FileInputStream
    java::import java.util.Properties
    set fileprop [java::new Properties]
    set fileStream [java::new FileInputStream $propFileName]
    $fileprop load $fileStream
    return $fileprop
}
proc getTraceValue {props spec} {
    puts stdout "entering getTraceValue"
    set traceValue [string trim [$props getProperty $spec]]
        puts "properties file value for $spec is  $traceValue"
    return $traceValue
}

if { !($argc == 4) } {
   puts "setServerTracing: this script requires 4 parameters: server name, node name, properties file, trace specification name"
   puts ""
   puts "e.g.:   wsadmin -f  setServerTracing.jacl server1 mynode tracing.properties arfm"
   exit
} else {

   set serverName      [lindex $argv 0]  
   set nodeName        [lindex $argv 1]  
   set propFile        [lindex $argv 2]
   set tsn             [lindex $argv 3]

   set props [loadProperties $propFile] 
   set traceValue [getTraceValue $props $tsn]

#--------------------------------------------------------------
# set up globals
#--------------------------------------------------------------
  global AdminControl
  global AdminConfig
#---------------------------------------------------------
# Get the TraceService MBean for this server 
#---------------------------------------------------------
  set traceServ [$AdminControl completeObjectName type=TraceService,node=$nodeName,process=$serverName,*]
#---------------------------------------------------------
# Get the current value of traceSpecification 
#---------------------------------------------------------
  set spec [$AdminControl getAttribute $traceServ traceSpecification]
  puts "Current trace specification is $spec"
#---------------------------------------------------------
# Set it to something else 
#---------------------------------------------------------
  $AdminControl setAttribute $traceServ traceSpecification $traceValue
#---------------------------------------------------------
# Now get the current value of traceSpecification again 
#---------------------------------------------------------
  set spec [$AdminControl getAttribute $traceServ traceSpecification]
  puts "Current trace specification is now $spec"
  $AdminConfig save
}

 

Example of the properties file that is required by the script.

TraceSpec.properties

arfm_node=com.ibm.ws.xd.comm.*=all:com.ibm.ws.xd.placement*=all:com.ibm.ws.xd.arfm.*=all
arfm_odr=com.ibm.ws.xd.comm.*=all:com.ibm.wsmm.grm.Controller=all:com.ibm.ws.xd.work*=all:com.ibm.ws.xd.arfm.*=all:com.ibm.wsmm.policing.*=all:com.ibm.wsmm.xdglue.*=all:com.ibm.ws.odc.ODCTreeImpl$Save=all
charting=com.ibm.ws.console.chart.*=all
dcs=DCS=finest:RMM=finest
dmgr=com.ibm.ws.odc.*=all:com.ibm.ws.xd.visualizationengine.cacheservice.cacheimpl.DeploymentTargetCache*=all
dwlm=com.ibm.ws.dwlm.*=all
grid=grid.capacityplacement=all
ham=hamanageditem=all
odc=com.ibm.ws.odc.*=all:com.ibm.ws.dwlm.client.*=all:com.ibm.ws.xd.dwlm.client.*=all:com.ibm.ws.proxy.*=all
operationalpolicy=com.ibm.ws.xd.operationalpolicymonitor.*=all
placement=com.ibm.ws.xd.placement*=all=enabled
proxy=com.ibm.ws.console.proxy.*=all
runtime=com.ibm.ws.console.xdruntime.*=all
tcp=com.ibm.ws.tcp.channel.*=finest
tcpdcs=DCS=finest:RMM=finest:com.ibm.ws.tcp.channel.*=finest
vizcache=com.ibm.ws.xd.visualizationengine.cacheservice.cacheimpl.*=all
webcontainer=com.ibm.ws.webcontainer.*=all:com.ibm.ws.http.*=all
reset=*=info