Skip to content

Use of extra field in messageΒ #32

@jonyscathe

Description

@jonyscathe

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions