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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public static SerilogExtensionsOptions AddApplicationServicesEnricher(this SerilogExtensionsOptions options)
 {
     options.ApplicationServices.AddSingleton <ILogEventEnricher, ApplicationServicesEnricher>();
     return(options);
 }
예제 #4
0
 public static SerilogExtensionsOptions AddCorrelationEnricher(this SerilogExtensionsOptions options)
 {
     options.ApplicationServices.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     options.ApplicationServices.AddSingleton <ILogEventEnricher, CorrelationEnricher>();
     return(options);
 }