You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I read in aspnet/Logging#182 this project will use the ILogger implementation from Log.Logger if none is specified.
I understand and appreciate the need for the static/global Log; however, its seems out of place to me in cases where dependency injection is first class like in the ASP.NET 5 framework. There, it would seem more appropriate to get one from the IServiceProvider that is used for dependency resolution.
While, the current implementation works and users can choose to resolve via the DI mechanism themselves; however, I am wondering whether it would be worthwhile to have an API where serilog-framework-logging would try to resolve/retrieve the ILogger before falling back to the static Log. This could be an extension method on IApplicationBuilder that uses IApplicationBuilder.ApplicationServices meaning usage would be along the lines of app.UseSerilog().
The text was updated successfully, but these errors were encountered:
Thanks for the feedback; I'm keen to see how things fall out from usage. The Log class is always going to be around, so no API like this could be watertight - so unless Log is configured it will always be possible to call it (and preferable in many cases I think, since the overhead of a DI resolve is going to significant if it is done for every static logging call).
It'd be interesting to see a PoC if you end up with one - it'd be great if you are able to share your experiences here. I might close this for now as I don't think it's something we'll tackle in the short term in this project.
I read in aspnet/Logging#182 this project will use the
ILogger
implementation fromLog.Logger
if none is specified.I understand and appreciate the need for the static/global
Log
; however, its seems out of place to me in cases where dependency injection is first class like in the ASP.NET 5 framework. There, it would seem more appropriate to get one from theIServiceProvider
that is used for dependency resolution.While, the current implementation works and users can choose to resolve via the DI mechanism themselves; however, I am wondering whether it would be worthwhile to have an API where serilog-framework-logging would try to resolve/retrieve the ILogger before falling back to the static
Log
. This could be an extension method onIApplicationBuilder
that usesIApplicationBuilder.ApplicationServices
meaning usage would be along the lines ofapp.UseSerilog()
.The text was updated successfully, but these errors were encountered: