> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shuttle.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Logs

> Tracing or logging in Shuttle apps.

Shuttle records build logs and anything your application writes to `stdout` and `stderr`.

## Viewing Logs

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

```bash theme={null}
shuttle logs
```

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

```bash theme={null}
shuttle logs <id>
```

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

```bash theme={null}
shuttle deployment list
```

The `--latest` or `-l` flag will get the logs from the most recently created deployment:

```bash theme={null}
shuttle logs --latest
```

To view logs without the timestamps and log origin tags:

```bash theme={null}
shuttle logs --raw
```

## Default Tracing Subscriber

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 by disabling the default features on `shuttle-runtime`:

```toml Cargo.toml theme={null}
shuttle-runtime = { version = "0.57.0", default-features = false }
```

With the default features enabled you can skip the step of initializing your subscriber when implementing [tracing](https://docs.rs/tracing/latest/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!

```rust theme={null}
use tracing::info;

#[shuttle_runtime::main]
async fn main() -> ... {
    info!("Starting up");

    // ...
}
```

If you'd rather use [log](https://docs.rs/log/latest/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="..." shuttle run` or `shuttle run --debug`.

Deployments use `RUST_LOG="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 `shuttle logs` commands.

We've created an example Actix Web app with a simple `tracing`: [custom tracing example](https://github.com/shuttle-hq/shuttle-examples/tree/main/tracing/custom-tracing-subscriber).
