Skip to content

logging API should expose file or class name + method name at least #110737

Open
@rmannibucau

Description

@rmannibucau

Logger frameworks log the source of the log message.
In can be (file+method) or (class+method) - optionally with line number - but this is key to have some usefulness of the logs until you do it manually everywhere.

There are some options to do it and I think injecting this data in a scope is not that bad. Using caller attributes appended to LoggerExtensions can make sense but will break the params parameter.
Using an extension/stackframe to get the caller is too expensive (perf).

Ideally the scope option would be neat if scope is included in the formatters of the logger providers (purely for perf).

Side note: making it compatible with the logger source generator would be good as well - can use the caller attribute option.

What stays key is to 1. have it and 2. have it structured (when logging in JSON for example) and not in the log message.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions