public static ILoggingBuilder AddElasticCloud(this ILoggingBuilder builder, string cloudId, string username, string password) { if (string.IsNullOrEmpty(cloudId)) { throw new ArgumentException("cloudId may not be empty.", nameof(cloudId)); } if (string.IsNullOrEmpty(username)) { throw new ArgumentException("username may not be empty.", nameof(username)); } if (string.IsNullOrEmpty(password)) { throw new ArgumentException("password may not be empty.", nameof(password)); } builder.AddElasticsearch(); void configure(ElasticsearchLoggerOptions options) { options.ShipTo.ConnectionPoolType = ConnectionPoolType.Cloud; options.ShipTo.CloudId = cloudId; options.ShipTo.Username = username; options.ShipTo.Password = password; } builder.Services.Configure((Action <ElasticsearchLoggerOptions>)configure); return(builder); }
/// <summary> /// Adds a file logger named 'File' to the factory. /// </summary> /// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param> /// <param name="configure"></param> public static ILoggingBuilder AddElasticsearch(this ILoggingBuilder builder, Action <EsLoggerOptions> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } builder.AddElasticsearch(); builder.Services.Configure(configure); return(builder); }
public static ILoggingBuilder AddElasticsearch(this ILoggingBuilder builder, Action <ElasticsearchLoggerOptions> configure, Action <ElasticsearchChannelOptions <LogEvent> > configureChannel ) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } if (configureChannel == null) { throw new ArgumentNullException(nameof(configureChannel)); } builder.AddElasticsearch(); builder.Services.Configure(configure); builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <IChannelSetup>(new ChannelSetup(configureChannel))); return(builder); }
public static ILoggingBuilder AddElasticCloud(this ILoggingBuilder builder, string cloudId, string apiKey) { if (string.IsNullOrEmpty(cloudId)) { throw new ArgumentException("cloudId may not be empty.", nameof(cloudId)); } if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentException("apiKey may not be empty.", nameof(apiKey)); } builder.AddElasticsearch(); void configure(ElasticsearchLoggerOptions options) { options.ShipTo = new ShipTo(cloudId, apiKey); } builder.Services.Configure((Action <ElasticsearchLoggerOptions>)configure); return(builder); }