nreco / logging

Generic file logger for .NET Core (FileLoggerProvider) with minimal dependencies
MIT License
284 stars 56 forks source link

Add scope support #19

Closed TIPConsulting closed 3 years ago

TIPConsulting commented 3 years ago

Would it be possible to add Scope support? I'm not quite sure what level of effort it entails, but these pages seem to lay out a basic implementation

https://www.meziantou.net/asp-net-core-json-logger.htm

https://www.codeproject.com/Articles/1556475/How-to-Write-a-Custom-Logging-Provider-in-ASP-NET

VitaliyMF commented 3 years ago

As I know, logging provider is not obligated to support scopes (even some built-in logging providers don't support scopes).

If you have a vision how to add scopes support to NReco.Logging.File (with a backward compatibility) your contribution is welcome.

TIPConsulting commented 3 years ago

I'll see what I can do

TIPConsulting commented 3 years ago

My plan for now is to leave the default output formatter as-is. I will add a scope collection to the LogMessage objects and users can implement a custom output formatter to write them to file if required

VitaliyMF commented 3 years ago

It seems scopes may add some overhead (even if scopes are not used in the app) and, actually, anyway require custom formatting, and this is not what I want for the lightweight and simple file logging provider.

Anyone who is looking for the scopes support may check @TIPConsulting implementation (thanks for that!): https://github.com/nreco/logging/pull/20