Is there a way to log all requests being received by actix-web irrespective of whether the endpoint exists or not?
It seems I need to use middleware for this, is this the recommended approach?
Is there a way to log all requests being received by actix-web irrespective of whether the endpoint exists or not?
It seems I need to use middleware for this, is this the recommended approach?
There is logging middleware available as part of actix_web: actix_web::middleware::Logger
Middlewarefor logging request and response info to the terminal.Loggermiddleware uses standardlogcrate to log information.
Middleware is called for each request (so long no other middleware or route handles it beforehand), so putting it on your App at the top level should get all requests, whether the endpoint exists or not.
use actix_web::{middleware::Logger, App};
let app = App::new()
.wrap(Logger::default())
// ...