This repository contains the source code for the Decos.Diagnostics packages. There are currently four available packages:
- Decos.Diagnostics contains the basic abstractions and extensions for logging.
- Decos.Diagnostics.Trace contains a System.Diagnostics.TraceSource implementation and some trace listeners that write to the console or to a Logstash input.
- Decos.Diagnostics.AspNetCore provides both of the above packages in addition to some extensions for ASP.NET Core compatibility, such as dependency injection configuration extensions and a shutdown handler to allow for flushing logs that haven't been sent yet.
- Decos.Diagnostics.Trace.Slack provides a trace listener that sends logs to Slack using a web hook.
Use the LogFactoryBuilder class to configure and obtain a LogFactory or use the IServiceCollection.AddTraceSourceLogging extension method to configure the ILog, ILog<T> and ILogFactory interfaces for dependency injection.
When using any async trace listener, such as the Logstash or Slack trace listeners, you need to give them time to gracefully shutdown in order to prevent the potential loss of logged information. This can be done with the ShutdownAsync method on the LogFactory instance that was constructed at the start. Alternatively, When using the IServiceCollection.AddTraceSourceLogging extension method, an application shutdown handler is installed to take care of this when ASP.NET Core is shutting down.