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

Use of extra field in message #32

Open
jonyscathe opened this issue Apr 12, 2022 · 0 comments
Open

Use of extra field in message #32

jonyscathe opened this issue Apr 12, 2022 · 0 comments

Comments

@jonyscathe
Copy link

Hi,

I'm a bit confused by your example of how logging should be done for non-constant data.

I don't think your example in the readme works.

logger.info(
    "Hello {world}",
    extra=dict(
        world="Earth"
    )
)

Just leads to "Hello {world}" being logged as the extra dictionary is for filling in format arguments.
So something like:

logging.basicConfig(format="%(message)s %(world)s")
logger.info(
    "Hello",
    extra=dict(
        world="Earth"
    )
)

Will print out "Hello Earth", but obviously that isn't so useful for logging non-constant data that you don't want in every log message.
Am I missing something in my logging config that allows the extra dict to be used as you suggest?

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