Shuttle will record anything your application writes to stdout, e.g. a tracing or log crate configured to write to stdout, or simply println!. By default, Shuttle will set up a global tracing subscriber behind the scenes. If you’d rather set up your own tracing or logging, you can opt-out of the default subscriber by disabling the default features on shuttle-runtime:

Cargo.toml
shuttle-runtime = { version = "*", default-features = false }

Default Tracing Subscriber

With the default features enabled you can skip the step of initializing your subscriber when implementing tracing in your application, all you have to do is add tracing as a dependency in your Cargo.toml, and you’re good to go!

// [...]
use tracing::info;

#[shuttle_runtime::main]
async fn axum(#[shuttle_shared_db::Postgres] pool: PgPool) -> ShuttleAxum {
    info!("Running database migration");
    pool.execute(include_str!("../schema.sql"))
        .await
        .map_err(CustomError::new)?;

    // [...]
}

If you’d rather use log, everything from the above section on tracing applies. A log-compatible layer is added to the global subscriber, so like with tracing, all you need to do to use log macros in your project is add it to your Cargo.toml.

Configuring the default subscriber

The global subscriber has an env_filter which defaults to the INFO log level if no RUST_LOG variable is set. You can change the log level for local runs with RUST_LOG="..." cargo shuttle run.

Deployments use RUST_LOG="shuttle=debug,info", and this is not configurable at the moment. A custom subscriber can be set up instead.

Custom logging setup

If you opt-out of the default subscriber, you can set up logging or tracing the way you would in any other Rust application. The only thing you need to ensure is that your setup writes to stdout, as this is what Shuttle will record and return from the cargo shuttle logs commands.

We’ve created an example Actix Web app with a simple tracing: custom tracing example.

Viewing Logs

We have a few commands that are useful for viewing your application’s logs.

To view the logs for your current running deployment, if there is one:

cargo shuttle logs

Caveat: The above command finds the oldest deployment in the running state. related issue

You can also view logs of a specific deployment by adding the deployment id to this command:

cargo shuttle logs <id>

To get the deployment ID, you can run this command to view your deployment history:

cargo shuttle deployment list

The --latest flag will simply get the logs from the latest deployment (at the top of the table):

cargo shuttle logs --latest

And last but not least, if you’d like a live feed of your logs (from a running deployment):

cargo shuttle logs --follow