reqwest
reqwest copied to clipboard
How to enable logging for all requests/responses
Hi, I have a module with reqwest and eng_logger.
Is it possible to enable logging so reqwest uses log to to print all requests and responses? I would like to see the endpoint, headers, body, etc.
If this is possible, how?
thank you
The only way to fully log all the data you're asking for is to also set the connection_verbose() Client builder option, and then enable logging.
Just to show an example...
let client = reqwest::Client::builder().connection_verbose(true).build().unwrap();
Add env_logger to your Cargo.toml and enable it when your application starts...
async fn main() {
env_logger::init();
// ...
}
To enable maximum logging for reqwest, use trace level logging; e.g. start your application with:
RUST_LOG=reqwest=trace cargo run