Improve logging information, encode strings while building xml

This adds some additional logger statements, to make tracking down issues easier, and encodes strings while building the xml