# Do you enable tracing-subscriber for tests?

**URL:** <https://users.rust-lang.org/t/do-you-enable-tracing-subscriber-for-tests/140830>\
**Category:** help\
**Created:** [June 19, 2026, 6:47pm UTC](https://users.rust-lang.org/t/do-you-enable-tracing-subscriber-for-tests/140830 "2026-06-19T18:47:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PuercoPop](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/puercopop/32/36997_2.png) [@PuercoPop](https://users.rust-lang.org/u/PuercoPop)\
**Post date:** [June 19, 2026, 6:47pm UTC](https://users.rust-lang.org/t/do-you-enable-tracing-subscriber-for-tests/140830/1 "2026-06-19T18:47:58Z")

</div>

One of the pain points when writing tests for Axum applications is debugging what went wrong. One thing I've been doing is keeping a test helper to setup a tracing subscribing on my test helpers to add to the test when debugging. i.e.

```rust
// t.rs
#[allow(unused)]
pub(crate) fn setup_tracing() {
    let _ = tracing_subscriber::fmt()
        .with_env_filter("debug,tower_http=trace")
        .with_test_writer()
        .try_init();
}
...
#[tokio::test]
async fn test_foo() -> Result<()> {
  t::setup_tracking();
  ...
}

```

I'm curious if people instead always setup tracing when running tests. And if so where would they enable it? AFAIU Rust's built-in test runner doesn't have something like Go's [TestMain](https://pkg.go.dev/testing#hdr-Main)

* * *

I'm also curious what debugging strategies besides `println!` do y'all use.

---

<div class="post-metadata">

**Author:** ![danjl1100](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/danjl1100/32/10835_2.png) [@danjl1100](https://users.rust-lang.org/u/danjl1100)\
**Post date:** [June 21, 2026, 1:20pm UTC](https://users.rust-lang.org/t/do-you-enable-tracing-subscriber-for-tests/140830/2 "2026-06-21T13:20:01Z")

</div>

I've had some success with [`Once`](https://doc.rust-lang.org/stable/std/sync/struct.Once.html) initializing tracing only once for tests, but I haven't tried `with_test_writer()`... I assume that makes it nicer to only show the output if the test fails (or nocapture behavior)?

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [September 19, 2026, 1:20pm UTC](https://users.rust-lang.org/t/do-you-enable-tracing-subscriber-for-tests/140830/3 "2026-09-19T13:20:35Z")

</div>

Closed on September 19, 2026, 1:20pm UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
