Beispiel #1
0
        private static LogstashOptions LoadLogstashOptions(IConfiguration configuration)
        {
            var logstashOptions = new LogstashOptions();

            configuration.GetSection("serilog:logstash").Bind(logstashOptions);
            return(logstashOptions);
        }
Beispiel #2
0
        public static LoggerConfiguration Logstash(this LoggerSinkConfiguration sinkConfiguration, LogstashOptions logstashOptions, IDictionary <string, string> placeholders = null)
        {
            var index = BuildElasticIndex(logstashOptions.ElasticIndex, placeholders);

            return(sinkConfiguration.Http(
                       $"{logstashOptions.Url}/{index}",
                       batchFormatter: new ArrayBatchFormatter(),
                       textFormatter: new ElasticsearchJsonFormatter(),
                       httpClient: new BasicAuthenticatedHttpClient(logstashOptions.UserName, logstashOptions.Password)));
        }