public static SerilogExtensionsOptions AddMessagEnricher(this SerilogExtensionsOptions options, Action <MessageEnricherOptions> setupAction) { if (setupAction == null) { throw new ArgumentNullException(nameof(setupAction), $"{nameof(setupAction)} can not be null."); } options.ApplicationServices.Configure(setupAction); options.ApplicationServices.AddSingleton <ILogEventEnricher, MessageEnricher>(); return(options); }
public static IServiceCollection AddSerilogExtensions(this IServiceCollection services, Action <SerilogExtensionsOptions> setupAction) { if (setupAction == null) { throw new ArgumentNullException(nameof(setupAction), $"{nameof(setupAction)} can not be null."); } var options = new SerilogExtensionsOptions(services); setupAction.Invoke(options); return(services); }
public static SerilogExtensionsOptions AddApplicationServicesEnricher(this SerilogExtensionsOptions options) { options.ApplicationServices.AddSingleton <ILogEventEnricher, ApplicationServicesEnricher>(); return(options); }
public static SerilogExtensionsOptions AddCorrelationEnricher(this SerilogExtensionsOptions options) { options.ApplicationServices.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); options.ApplicationServices.AddSingleton <ILogEventEnricher, CorrelationEnricher>(); return(options); }