Added logging to stdout and stderr.