3

I would like to enable trace for DB2 which I'm accessing via datasource in WebSphere Application Server version 8.

Gas
  • 17,601
  • 4
  • 46
  • 93
Marko
  • 570
  • 5
  • 21

3 Answers3

4

In the server's bootstrap.properties file after the variable com.ibm.ws.logging.trace.specification= add the following code:

for version 6 or later:

 *=info:WAS.j2c=all:RRA=all:WAS.database=all:Transaction=all

for version 5:

RRA=all=enabled:WAS.database=all=enabled:J2C=all=enabled

More info can be found on IBM website: https://www-304.ibm.com/support/docview.wss?rs=71&uid=swg21196160#wasconnection

In you datasource you need to specify the traceLevel property as well. Example:

<dataSource id="db2" jndiName="jdbc/db2" jdbcDriverRef="DB2Driver" >
    <properties.db2.jcc databaseName="myDB" traceLevel="-1"/>
</dataSource> 
M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
2

Actually it depends on the WebSphere version and the way DB2 is used. I'll try to summarize your options, for more details look at the links at the bottom.

WebSphere Application Server (Full Profile)

You have the following options:

  1. You can enable general database related tracing via WebSphere tracing infrastructure.
    In the WebSphere web admin console go to Troubleshooting > Logging and tracing > serverName > Change log detail levels and either on the Runtime tab (effective immediately) or on Configuration tab (effective after restart) set the trace to *=info:WAS.database=all or more detailed *=info:WAS.j2c=all:RRA=all:WAS.database=all:Transaction=all. This trace string is general, for JDBC connection, not only for DB2.

  2. You can enable DB2 datasource trace related options.
    In the WebSphere web admin console go to Resources > JDBC > Data sources > datasourceName > Custom properties. Im the custom properties set trace related properties, the most important ones are:

    • traceLevel - specifies the level of trace, determined by a bitwise combination of constants:
TRACE_NONE=0, 
TRACE_CONNECTION_CALLS=1, 
TRACE_STATEMENT_CALLS=2, 
TRACE_RESULT_SET_CALLS=4, 
TRACE_DRIVER_CONFIGURATION=16, 
TRACE_CONNECTS=32, 
TRACE_DRDA_FLOWS=64, 
TRACE_RESULT_SET_META_DATA=128, 
TRACE_PARAMETER_META_DATA=256, 
TRACE_DIAGNOSTICS=512, 
TRACE_SQLJ=1024, 
TRACE_META_CALLS=8192, 
TRACE_DATASOURCE_CALLS=16384,
TRACE_LARGE_OBJECT_CALLS=32768,
TRACE_SYSTEM_MONITOR=131072,
TRACE_TRACEPOINTS=262144, 
TRACE_ALL=-1.
  • traceFile - specifies file to store the trace output

WebSphere Liberty Profile

In the folder LIBERTY_HOME/usr/servers/server_name create bootstrap.properties with the following variable for DB2 (for other databases check link at the bottom):

com.ibm.ws.logging.trace.specification=*=audit=enabled:com.ibm.ws.db2.logwriter=all=enabled

Specifying trace via system property

When you use unmanaged connections got from DriverManager, you cannot set driver trace properties via data source. In that case you can create property file with the following contents:

db2.jcc.traceDirectory=/tmp/jcctrace
db2.jcc.traceFile=trace
db2.jcc.traceFileAppend=false
db2.jcc.traceLevel=-1

and specify path to it as JVM system property:

-Ddb2.jcc.propertiesFile=pathToFile/fileName.properties

Useful links:

Gas
  • 17,601
  • 4
  • 46
  • 93
2

for version 6 or later:

*=info:WAS.j2c=all:RRA=all:WAS.database=all:Transaction=all

And for version 5:

RRA=all=enabled:WAS.database=all=enabled:J2C=all=enabled

Adam
  • 21
  • 2