Changing WAS Log Detail Level

WebSphere command assistant and command log are extremely helpful to create WAS automation scripts, but these do not cover many commands from troubleshooting and monitoring sections of the WebSphere integrated console. I wish documentation would be better too. It takes some time to find the right object, and it require to run multiple tests before the task can be scripted.
Here is an example of Jython script using AdminTask object to update to update WAS Log Detail Level.

##########################################################
# Updating log detail level
# Default settings are "*=info"
# it can be changed by providing LOGDETAILS 
# in the command line: LOGDETAILS="*=info: ...."
#########################################################
DEBUG = 1
# default parameters
pars = { 
	'LOGDETAILS'   : '*=info'
}
 
#########################################################
# update defaults from command line
#########################################################
for arg in sys.argv:
	arr = arg.split("=", 1)
	if len(arr) > 1:
		pars[arr[0].upper()] = arr[1]
 
if DEBUG :
	for key in pars.keys():
		print key + " = '" + pars[key] + "'"
 
# get server and node names
objNameString = AdminControl.completeObjectName('WebSphere:type=Server,*')
node   = AdminControl.getAttribute(objNameString, 'nodeName');
server = AdminControl.getAttribute(objNameString, 'name');
 
#########################################################
# update settings
#########################################################
try:
	_excp_ = 0
	AdminTask.setTraceSpecification('[-serverName ' + server + \
		' -nodeName ' + node + \
		' -persist true -traceSpecification "' + pars['LOGDETAILS'] + '"]')
	# Save to master configuration
	AdminConfig.save()	
except:
	_type_, _value_, _tbck_ = sys.exc_info()
	result = `_value_`
	_excp_ = 1
#endTry 
if (_excp_ ):
	print "Error = " + result
#endIf

Leave a Reply

Your email address will not be published. Required fields are marked *