Add support for LoggerExtensions.BeginScope method
See original GitHub issueWould love to see support for the LoggerExtensions.BeginScope
method in Microsoft.Extensions.Logging:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loggerextensions.beginscope
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
LoggerExtensions.BeginScope(ILogger, String, Object[]) ...
Formats the message and creates a scope.
Read more >Creating an extension method for attaching key-value pairs ...
In this post I describe a small extension method that makes logging scopes as key-value pairs in ASP.NET Core with Serilog and Seq...
Read more >The semantics of ILogger.BeginScope()
The BeginScope() extension method used here creates an instance of the internal FormattedLogValues class, which is IEnumerable<KeyValuePair< ...
Read more >Microsoft.Extensions.Logging custom implementation, how ...
Extension method for logging dotnet core webapi how do I get the calling projects/assembly name? 2 · Add method to existing Microsoft.Extensions ...
Read more >Logging with ILogger in .NET: Recommendations and best ...
This article describes recommendations and best practices for using the ILogger based logging system which has been introduced with .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @iam-black
My bad, I forgot to add
.Enrich.FromLogContext()
in the logger configuration. Yes, your code should definitely work.This is probably worth implementing, but this won’t be easy because you should investigate the entire call stack to determine the context. I’ll gladly accept PR.
Also, I’d like to mention that the main usage of the scope is to avoid repetition and add context to messages. We are using Elastic for logging too, and we attach the context properties to log messages without rendering them in the templates. In other words, we don’t put properties from scope to templates because they are attached anyway, and you can use them in Kibana filters.
Interesting, I’ll take a look when I have spare time.