Add a logging middleware.