JACL to configure logging in websphere

ibm websphere
Below JACL script can be used to configure logging in websphere (trace service, Debug service & Custom service).
#----------------------------------------------------------------------------------------
#-- Configuring trace service 
#----------------------------------------------------------------------------------------

set aServer [$AdminConfig getid /Node:myNode/Server:newServer/]
set aTraceService [$AdminConfig list TraceService $aServer]

# Modify trace specification to enable trace
puts "Modify trace specification"
set traceSpecAttr [list startupTraceSpecification com.ibm.websphere.management.*=all=enabled]
$AdminConfig modify $aTraceService [list $traceSpecAttr]
puts [$AdminConfig show $aTraceService]

# modify to use memory buffer as the trace output. Valid values are SPECIFIED_FILE or MEMORY_BUFFER
puts "Modify trace output type and size"
set typeAttr [list traceOutputType MEMORY_BUFFER]
# memory buffer size is specified in number of thousand entries
set sizeAttr [list memoryBufferSize 10]
set attrs [list $typeAttr $sizeAttr]
$AdminConfig modify $aTraceService $attrs
puts [$AdminConfig show $aTraceService]

$AdminConfig save

#----------------------------------------------------------------------------------------------
#-- Configuring debugging service 
#----------------------------------------------------------------------------------------------

set aServer [$AdminConfig getid /Node:myNode/Server:newServer/]
set aJVM [$AdminConfig list JavaVirtualMachine $aServer]
set debugAttr [list debugMode true]
set debugArgAttr [list debugArgs "-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n, address=7777"]
set attrs [list $debugAttr $debugArgAttr]
$AdminConfig modify $aJVM $attrs
$AdminConfig save

#----------------------------------------------------------------------------------------------
#-- Configuring custom service 
#----------------------------------------------------------------------------------------------

set aServer [$AdminConfig getid /Node:myNode/Server:newServer/]

# setting up properties for a new custom service
puts "Set up properties for a new custom service"
set nameAttr [list displayName myCustomService]
set classnameAttr [list classname com.my.custom.myCustomService]
set classpathAttr [list classpath /mylib/myCustomService.jar]
set descAttr [list description "my custom service"]
# enable start up of this service when the application server starts
set enableAttr [list enable true]
set attrs [list $nameAttr $classnameAttr $classpathAttr $descAttr $enableAttr]

puts "Create a new custom service"
set newCustomService [$AdminConfig create CustomService $aServer $attrs]
puts [$AdminConfig show $newCustomService]

# create a new custom property
puts "Create a new custom property for the created custom service"
set nameAttr [list name customServiceProperty1]
set valueAttr [list value customServiceValue1]
set propertyAttrs [list $nameAttr $valueAttr]
set property [$AdminConfig create Property $newCustomService $propertyAttrs]
puts [$AdminConfig show $property]

$AdminConfig save

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.