Relations Between Category and Location
Use
It is common practice to look at the log and trace messages together when you perform a diagnosis. A correlation between a problematic area and the source code location that generates the problem is highly desired.
More information: Message Output with Severity .
Example
This example only shows the attachment of a location to a category but this is relevant for the opposite case, too.
package com.sap.fooPackage; import com.sap.tc.logging.*; public class Node { private static final Location loc = Location.getLocation("com.sap.fooPackage.Node"); private static final Category objMgmt = Category.getCategory("/Objects/Management"); public void announce(Object o) { final String method = "announce(java.lang.Object)"; loc.entering(method, new Object[] { o }); try { // Register object ... } catch (RegistrationException e) { objMgmt.errorT(loc, method, "Error registering new object {0}.", Object[] {o}); } loc.exiting(); } // method announce } // class Node
Output
The category objMgmt outputs two messages - a log message and a trace message. These messages have the same message ID for cross-referencing each other. This makes the analysis more comfortable.
There is a possibility for the configuration to already be defined in the initialization stage and to be effective to this local scope through the hierarchical inheritance logic.
More information:
Additional Configuration
It is possible to have more advanced configuration, regarding the correlated category and location source objects.