What Is the Difference Between log and tracing in Rust?

Logging records discrete events, while tracing tracks execution flow and context across asynchronous tasks and function boundaries.

Logging records discrete events with context, while tracing tracks the flow of execution across asynchronous tasks and function boundaries. Use tracing for distributed debugging and log for simple event recording.

[dependencies]
tracing = "0.1"
tracing-subscriber = "0.3"
use tracing::{info, span, Level};

fn main() {
    tracing_subscriber::fmt::init();
    let span = span!(Level::INFO, "request", id = 123);
    let _guard = span.enter();
    info!("processing request");
}