Don't encode user-agent header, added try/catch for fallback in logging