Set tracing via a profile

 

Set up a profile to make tracing easier. The following profile example turns tracing on and off...

Using Jacl

proc ton {} {
  global AdminControl
  set ts [lindex [$AdminControl queryNames type=TraceService,*] 0]
  $AdminControl setAttribute $ts traceSpecification com.ibm.=all=enabled
} 

proc toff {} {
  global AdminControl
  set ts [lindex [$AdminControl queryNames type=TraceService,*] 0]
  $AdminControl setAttribute $ts traceSpecification com.ibm.*=all=disabled
} 

proc dt {} {
  global AdminControl
  set jvm [lindex [$AdminControl queryNames type=JVM,*] 0]
  $AdminControl invoke $jvm dumpThreads 
} 

Using Jython

# get line separator 
import  java.lang.System  as  sys
lineSeparator = sys.getProperty('line.separator')

def ton()...
    global lineSeparator
    ts = AdminControl.queryNames('type=TraceService,*').split(lineSeparator)[0]

    AdminControl.setAttribute(ts, 'traceSpecification', 'com.ibm.=all=enabled')

def toff()...
    global lineSeparator
    ts = AdminControl.queryNames('type=TraceService,*').split(lineSeparator)[0]

    AdminControl.setAttribute(ts, 'traceSpecification', 'com.ibm.*=all=disabled')

def dt()...
    global lineSeparator
    jvm = AdminControl.queryNames('type=JVM,*').split(lineSeparator)[0]
    AdminControl.invoke(jvm, 'dumpThreads')

If you start the wsadmin tool with this profile, you can use the ton command to turn on tracing in the server, the toff command to turn off tracing, and the dt command to dump the Java threads. For more information about running scripting commands in a profile, see Launching Scripting Clients article.

 

See Also

wsadmin.sh