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

Roslyn Analyzer that pushes towards using the Format logger overloads instead of doing interpolation #283

Open
danielmarbach opened this issue Mar 27, 2024 · 0 comments

Comments

@danielmarbach
Copy link
Contributor

Describe the feature.

Is your feature related to a problem? Please describe.

No

Describe the requested feature

For log statements that do not require to log details of the exception prefer the *Format overloads like InfoFormat to allow logging libraries that support structured logging to extract the format template and the arguments. So instead of writing

Logger.Info($"Here is an informational log with {someValue}");

prefer

Logger.InfoFormat("Here is an informational log with {0}", someValue);

This allows semantic logger targets to easily filter on log message (Here is an informational log with {0}) and/or any of the provided arguments (0=='my value') where the first does not as that will only log strings without any context.

Describe alternatives you've considered

Given that we should move away from our current logging abstraction, investing time into such an analyzer might not be well spent but we leave it up to the people that take up this work to decide.

Additional Context

No response

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