Skip to content

Instantly share code, notes, and snippets.

@hgmauri
Created November 7, 2023 10:29
Show Gist options
  • Save hgmauri/0295c9eb595c3477d106715991afb396 to your computer and use it in GitHub Desktop.
Save hgmauri/0295c9eb595c3477d106715991afb396 to your computer and use it in GitHub Desktop.
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Async(writeTo => writeTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(configuration["ElasticsearchSettings:uri"]))
{
CustomFormatter = new EcsTextFormatter(),
AutoRegisterTemplate = true,
IndexFormat = "indexlogs",
ModifyConnectionSettings = x => x.BasicAuthentication(configuration["ElasticsearchSettings:username"], configuration["ElasticsearchSettings:password"])
}))
.CreateLogger();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment