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

Structured logging doesn't seem to work #540

Closed
svanharmelen opened this issue Dec 21, 2022 · 4 comments
Closed

Structured logging doesn't seem to work #540

svanharmelen opened this issue Dec 21, 2022 · 4 comments

Comments

@svanharmelen
Copy link

Hi 👋🏻 I'm trying write structured logs, but somehow the key/values seem to be ignored...

I have this in my Cargo.toml:

[dependencies]
env_logger = "0.10"
log = { version = "0.4.17", features = ["kv_unstable"] }

And this is main.rs:

use log::info;

fn main() {
    env_logger::builder()
        .filter_level(log::LevelFilter::Info)
        .init();
    info!(some = "thing"; "Hello, world!");
}

And when I run this I get this:
image

Any ideas? Am I missing anything or doing something wrong?

Thanks!

@Thomasdezeeuw
Copy link
Collaborator

I'm guessing the env_logger crate is not logging the values. You should file an issue here: https://github.com/rust-cli/env_logger.

@svanharmelen
Copy link
Author

If that is the case @Thomasdezeeuw, do you know which of the other loggers mentioned in the README does support structured logging?

I was under the impression that this was fully handled in this crate and no additional changed were needed by individual loggers.

@Thomasdezeeuw
Copy link
Collaborator

If that is the case @Thomasdezeeuw, do you know which of the other loggers mentioned in the README does support structured logging?

I have my own implementation: https://github.com/Thomasdezeeuw/std-logger. It supports logfmt and JSON (specifically the JSON format used by GCP).

I was under the impression that this was fully handled in this crate and no additional changed were needed by individual loggers.

Key-value logging is experimental, though I think we're pretty close to a stable release. That said, I think individual implementations still need to separately log the key-value pairs as they're exposed a separate field.

@svanharmelen
Copy link
Author

Thanks for the pointer @Thomasdezeeuw. Found this one which confirms your guess 😏 So I'll close this issue again...

rust-cli/env_logger#137

EFanZh pushed a commit to EFanZh/log that referenced this issue Jul 23, 2023
Add short name for no-confirm flag

Closes rust-lang#536

The -y short name is a convention, often used by package managers (apt, yum, ...) and it is associated with a request of no interaction (thus often used in scripts, to automate workflows)
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

2 participants