Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nothing is printed to the console if a no default log level is provided at runtime #3208

Closed
dprosper opened this issue Feb 2, 2025 · 1 comment

Comments

@dprosper
Copy link

dprosper commented Feb 2, 2025

Bug Report

Version

│   │   └── tracing v0.1.41
│   │       ├── tracing-attributes v0.1.28 (proc-macro)
│   │       └── tracing-core v0.1.33
│   │   │   └── tracing v0.1.41 (*)
│   │   └── tracing v0.1.41 (*)
│   │   └── tracing v0.1.41 (*)
│   └── tracing v0.1.41 (*)
│   │   │   └── tracing v0.1.41 (*)
│   │   ├── tracing v0.1.41 (*)
│   │   ├── tracing v0.1.41 (*)
│   │   │   │   │   └── tracing v0.1.41 (*)
│   │   │   └── tracing v0.1.41 (*)
│   │   ├── tracing v0.1.41 (*)
│   │   │   └── tracing v0.1.41 (*)
│   │   └── tracing v0.1.41 (*)
│   ├── tracing v0.1.41 (*)
│   └── tracing v0.1.41 (*)
│   ├── tracing v0.1.41 (*)
├── tracing v0.1.41 (*)
├── tracing-appender v0.2.3
│   └── tracing-subscriber v0.3.19
│       ├── tracing v0.1.41 (*)
│       ├── tracing-core v0.1.33 (*)
│       ├── tracing-log v0.2.0
│       │   └── tracing-core v0.1.33 (*)
│       └── tracing-serde v0.2.0
│           └── tracing-core v0.1.33 (*)
├── tracing-subscriber v0.3.19 (*)

Platform

Darwin Mac 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:23 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6031 arm64

Description

I tried this code (note that I removed additional subscribers that are not relevant to this issue):

    let console_layer = tracing_subscriber::fmt::layer()
        .pretty()
        .with_file(false)
        .with_line_number(false)
        .with_target(false)
        .with_writer(std::io::stdout)
        .with_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")));

    // Initialize combined registry
    Registry::default()
        .with(console_layer)
        .try_init()
        .expect("Failed to initialize logging.");

I expect when I run cargo run to have at minimum info, warn and error printed to the console.

Nothing gets printed to the console, only when I run RUST_LOG=info cargo run do I see info, warn and error lines printed to the console.

Dependencies in my Cargo.toml

[dependencies]
dotenvy = "0.15.7"
libsql = "0.6.0"
axum = "0.8.1"
tokio = { version = "1.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = "0.4.39"
tower-http = { version = "0.6.2", features = ["full"] }
metrics-exporter-prometheus = "0.16.1"
metrics = "0.24.1"
dialoguer = "0.11.0"
console = "0.15.10"
log = "0.4.25"
tower = "0.5.2"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "json", "parking_lot", "registry"] }
tracing-appender = "0.2.3"
rand = "0.9.0"
clap = { version = "4.5.27", features = ["derive", "env"] }
axum-extra = { version = "0.10.0", features = ["typed-header"] }
ulid = { version = "1.1.4", features = ["serde"] }
async-trait = "0.1.86"
anyhow = { version = "1.0.95", features = ["backtrace"] }
thiserror = "2.0.11"
@dprosper
Copy link
Author

dprosper commented Feb 4, 2025

I needed to "unset RUST_LOG".

@dprosper dprosper closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant