Add logging and tests for writing JSON to stderr.