code: static void debugLogMetadata(IIOMetadata metadata, String format)
      {
          if (!logger.isDebugEnabled())
          {
              return;
          }
  
          // see http://docs.oracle.com/javase/7/docs/api/javax/imageio/
          //     metadata/doc-files/standard_metadata.html
          IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(format);
          try
          {
              StringWriter xmlStringWriter = new StringWriter();
              StreamResult streamResult = new StreamResult(xmlStringWriter);
              Transformer transformer = TransformerFactory.newInstance().newTransformer();
              // see http://stackoverflow.com/a/1264872/535646
              transformer.setOutputProperty(OutputKeys.INDENT, "yes");
              transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
              DOMSource domSource = new DOMSource(root);
              transformer.transform(domSource, streamResult);
              logger.debug("\n" + xmlStringWriter);
          }
          catch (Exception e)
          {
              logger.error("Error while reporting meta-data", e);
          }
      }
docs: logs metadata as an XML tree if debug is enabled