Details
Description
Add more logging to TraceComponent.java, for the following:
- NormalizedMassage.getPropertyNames(): get the objects in some string format.
- If NormalizedMassage.getProperty() is of type javax.xml.transform.Source, convert the type of a String for logging
See below code for possible example:
/** * Outputs the properties on the {@link NormalizedMessage}. Properties of * type {@link Source} are transformed to a {@link String} before * being output. * * @param message The {@link NormalizedMessage} to be processed */ @SuppressWarnings("unchecked") protected void outputProperties(NormalizedMessage message) { // Loop over all the properties on the normalized message for (Object o : message.getPropertyNames()) { // NormalizedMessage API does not use generics. This interface is // written in Java older than 5.0. On the basis of other methods and // the default implementation of this interface we can assume that // only String keys are allowed. String key = (String) o; try { Object contents = message.getProperty(key); // Is this the only value type that we would like to treat // differently? The default behavior is to invoke toString() on // the object. if (contents instanceof Source) { contents = getSourceTransformer().toString((Source) contents); } log.info("Value for property '" + key + "' is: " + contents); } catch (TransformerException e) { log.error("Failed to turn property '" + key + "' value into text: " + e, e); } } }