XStream is extremely good at printing object graphs, even processing cycles, without any additional setup or extra code in your classes (i.e. mess with toString ()). Just add a library, and you can do it on anything and get a nice, useful conclusion:
log.debug("The object: {}", new XStream().toXML(anyObject));
This will give you XML output. If you prefer JSON, you can get it with a little extra work, described in detail in the XStream JSON tutorial .
source share