-
Notifications
You must be signed in to change notification settings - Fork 244
What's the future of log abstractions like ASP.NET 5 ILogger, LibLog, EventSource, ... #332
Description
Hi everyone! This is a rather philosophical question but still, it would be great if I could get some opinions from you guys!
I'm currently working on a quite big new "microservices"-like project with many services. Routing all log entries into one central repository is a key to success in my opinion. Therefore I've been reading a lot about this topic lately and unfortunately the more I read the less I like the current logging ecosystem in .NET.
It's quite common nowadays to rely on many different libraries - NuGet makes it incredibly easy to just drop in one library after the other into your project. Before systems like LibLog came up, there were hard dependencies on log4net or others - so LibLog and so on were a great step forward.
However I feel like what was done wrong with the direct depencies to logging frameworks is now just put up one level and repeated for "logger abstractions" or "logging emitters" (in other words: classes like a typical ILogger that actually >create< log entries)
I'm working on a greenfield project but still I already had to deal with the following logging emitters:
- LibLog (in IdentityServer3)
- Castle ILogger (in a library called "asp.net boilerplate")
- Microsoft.Owin.Logging (especially for authentication libraries)
- System.Diagnostics.Trace / TraceSource (Owin logs there by default and it seems to be the preferred way for Azure Web Apps if you want to use some built-in debugging functionality)
- System.Diagnostics.EventSource (we are using Azure Service Fabric to host our services and the .NET framework itself emits useful information through these)
- this new ILogger in Microsoft.Extensions.Logging (I do like the implementation, however I'm not happy with the fact that there is yet another ILogger)
None of these emitters actually store logs somewhere and if you don't configure them they just log into void. I'm having a really hard time to figure out the best way to get all of them into one repository. I'm currently routing most of them through Serilog (by writing a few adapters) but still, it doesn't work well (I don't get some EventSource entries, ...). What also frustrates me about this is the fact that you can't easily reuse this logic throughout your applications since every application depends on different abstractions. This makes it really painful in a microservice environment. I don't want my developers to think about this topic whenever they create a new service.
I'm also frustrated that all of this configuration is just for one technology stack in a very big logging architecture. There are so many other things that have to be aggregated as well. (infrastructure logging like nagios, windows event logs, IIS logs, ...)
So I don't understand why there isn't one good solution in the .NET framework itself for such an important topic. System.Diagnostics.Tracing.EventSource seems to be the most recent solution but it feels like it doesn't get enough attention and the tooling around it isn't very good in my opinion. Its rather static nature also makes it somehow hard to adopt in a system with many components. Much has been improved lately, but there are still many things that are hard to understand. E.g. would the ASP.NET 5 ecosystem have one EventSource per library? ... I still haven't got my head around it completely...
And if there's no sufficient solution in the framework itself, why haven't we as a community managed to reach 1 or 2 de-facto standards within the 15 years of .NET?
What do you think where we should head as a community?
Should we invest more into a built-in system like "EventSource" which seems to be the recommended solution from the .NET team? Its adoption within the framework itself basically makes it a "problem" we have to solve anyway in my opinion.
Should a system like LibLog be able to aggregate some of these other abstractions??
Should we actually go "back" and have hard dependencies on a system like Serilog that can emit and store events?
Or do we need yet another layer which basically does the opposite as the existing systems and acts like an aggregater who can read events from Trace, TraceSource, EventSource, LibLog, Common.Logging, ASP.NET 5 ILogger, ... and offers them in one central stream which then can be consumed by e.g. log4net/serilog - and how would such a system handle DLL dependencies??
And really important - where would be a good place to discuss this issue with the major stakeholders? Because the most important thing in my opinion is to NOT end up with yet another ILogger.
@nblumhardt, @vancem, @davidfowl, @damianh - As owners/main contributors to some of these systems, I hope it's ok to cc you for this question especially. Is this something you think should be discussed in more detail??
Or do you think I'm seeing a problem where there isn't one? :)
I'd really appreciate your feedback!!