How to enable OSB tracing from WLST =================================== Message tracing is a handy feature of OSB. However it is annoying to manually enable it after every redeploy. Oracle provides documentation on several MBeans to manipulate OSB deployments. Unfortunately the message tracing facility isn't in that list. It took me some time to find a way to automate that simple task. My first approach was through JDI - I was recording method entry events while manually enabling message tracing in sbconcole. Even with a class filter and exlusions, the amount of events was overwhelming and Weblogic became so slow that browser easily reached its connection timeout. However the debug traces draw my attention to the `ServiceConfigurationMBean`. This MBean provides undocumented API to many features that otherwise may only be accessible manually (as of OSB 11.1.1.6). The main challenge was to obtain a proxy of the MBean because usual `findService()` invocation returns `null` in its case. I'm sure some OSB developers and dev-ops will like it, so I've made up a rather simplistic WLST script. Sure it lacks proper error handling but it's already useable and a good point to start anyway. Of course one have to take care of the WLST environment and classpath before executing the script $ source $MW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh $ export CLASSPATH=$CLASSPATH:$MW_HOME/Oracle_OSB1/lib/sb-kernel-api.jar:\ $MW_HOME/Oracle_OSB1/lib/sb-kernel-common.jar:\ $MW_HOME/Oracle_OSB1/lib/sb-kernel-impl.jar:\ $MW_HOME/Oracle_OSB1/lib/sb-kernel-resources.jar:\ $MW_HOME/Oracle_OSB1/lib/sb-kernel-wls.jar:\ $MW_HOME/Oracle_OSB1/lib/alsb.jar:\ $MW_HOME/Oracle_OSB1/modules/com.bea.common.configfwk_1.6.0.0.jar:\ $MW_HOME/Oracle_OSB1/modules/com.bea.alsb.statistics_1.3.0.0.jar $ wlst.sh msg_tracing.py The useful primitive script `msg_tracing.py`. You may notice that a reference to the `SessionManagementMBean` is obtained with `findService()` but for the `ServiceConfigurationMBean` I resort to basic JMX API: import fnmatch from com.bea.wli.sb.management.configuration import SessionManagementMBean from com.bea.wli.sb.management.configuration import ServiceConfigurationMBean # utility function for generic handling of proxy and business services def createMatcher(cases, configMB): def matcher(ref): for case in cases: if fnmatch.fnmatchcase(ref.getFullName(), case["pattern"]): configMB.setMessageTracingEnabled(ref, True) configMB.setMessageTracingLevel(ref, case["level"]) configMB.setMessageTracingMaxSize(ref, int(case["maxSize"])) print "Enabled message tracing for", ref return matcher # main flow execfile("msg_tracing_settings.py") connect(username, password, url) domainRuntime() sessionMB = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE) sessionName = "Session-" + str(System.currentTimeMillis()) sessionMB.createSession(sessionName) print "Created session", sessionName namePattern = "com.bea:Name=" + str(ServiceConfigurationMBean.NAME) + "." + str(sessionName) + ",Type=" + str(ServiceConfigurationMBean.TYPE) objName = mbs.queryNames(ObjectName(namePattern), None)[0] configMB = JMX.newMBeanProxy(mbs, objName, Class.forName(ServiceConfigurationMBean.TYPE)) matcher = createMatcher(cases, configMB) map(matcher, configMB.getProxyRefs()) map(matcher, configMB.getBusinessServiceRefs()) sessionMB.activateSession(sessionName, "Enabled message tracing") print "Successfully activated session", sessionName exit() It references `msg_tracing_settings.py` meant to keep variables separately. It is easier to have them both in the same working directory. username = "weblogic" password = "password" url = "t3://localhost:7001" # pattern: shell-style pattern to match one or more proxy or business services # level : one of "Terse", "Headers" or "Full" # maxSize: payload limit in bytes cases = [ { "pattern" : "RESTfulBilling/proxy/util/APIAuthProxyService", "level" : "Terse", "maxSize" : 1024 }, { "pattern" : "CommDeliveries/proxy/VATDeliveryProxyService", "level" : "Full", "maxSize" : 2048 }, { "pattern" : "TSMS/business/*", "level" : "Full", "maxSize" : 3072 } ]