Network Deployment (Distributed operating systems), v8.0 > Troubleshoot and support > Work with Diagnostic Providers
Associate a Diagnostic Provider ID with a logger
Overview
Associating the Diagnostic Provider ID with a logger can be done dynamically or through a static assignment.
Components whose diagnostics are managed through a Diagnostic Provider MBean should include the Diagnostic Provider ID (DPID) in all logged messages. In some cases a single logger always logs with the same DPID. In those cases, it is appropriate to statically associate the DPID with the logger. In other cases, a logger might log on behalf of various diagnostic domains. For example, although every data source has a separate Diagnostic Provider MBean, they all share the same logger. In those cases, the DPID can be dynamically supplied on each logging call.
Static Assignment
To statically assign a DPID to a logger.
Logger logger = Logger.getLogger("com.ibm.ws.MyClass");
DiagnosticProviderHelper.addDiagnosticProviderIDtoLogger(logger, dpid);
Dynamic Assignment
DPIDs can be associated with a single log request by including them as the first message parameter, prefixed with...
DPID:
To associate a DPID with a single log request using a logger:
Object[] parms = new Object[] { "DPID:" + dpid };
logger.logp(classname, methodname, "MSG0001", parms);
Note that in the dynamic case, the DPID does not need to actually show up in the formatted message. The two examples below illustrate:
// In resource bundle
// By not including {0} first parm is not printed in the message.
MSG0001=This message does not include the DPID.
// Note - it is not recommended to print the DPID in your message.
MSG0002=This message includes the DPID...it's value is {0}.
IBM recommends that messages not include the DPID in the formatted message. As shown above, this is done by not including {0} in the message value in the resource bundle.