Improved configure_logging to properly write to stdout or stderr on request.