© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
155 replies
qqdev

✅ Scoped-based logging: Microsoft interface

Hi! We are planning to make use of scoped-based logging.

using var scope1 = _logger.BeginScope(context.ToDictionary());
logContextInfomation.Foo = bar;
using var scope2 = _logger.BeginScope(context.ToDictionary());
using var scope1 = _logger.BeginScope(context.ToDictionary());
logContextInfomation.Foo = bar;
using var scope2 = _logger.BeginScope(context.ToDictionary());

We are not quite happy with this approach tho ^

Is there a less repetitive solution for this? We just want to apply the current context to every log message.

Thanks in advance!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Microsoft.Extensions.Logging.Console
C#CC# / help
2y ago
✅ Attribute based definition vs. Interface based definition
C#CC# / help
8mo ago
Microsoft.Extensions.Logging dynamic log level?
C#CC# / help
16mo ago
❔ Automatic discovery of scoped services without a marker interface
C#CC# / help
3y ago
Next page