Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save javierguerrero/8eacb9866a7e5ffc613fbb805d319a86 to your computer and use it in GitHub Desktop.
Save javierguerrero/8eacb9866a7e5ffc613fbb805d319a86 to your computer and use it in GitHub Desktop.
exception_handling_csharp_chapter7_5.cs
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.Elasticsearch(new Serilog.Sinks.Elasticsearch.ElasticsearchSinkOptions(new Uri("http://localhost:9200"))
{
IndexFormat = "logs-{0:yyyy.MM.dd}",
AutoRegisterTemplate = true,
})
.CreateLogger();
try
{
throw new InvalidOperationException("Operación inválida en microservicio");
}
catch (Exception ex)
{
Log.Error(ex, "Error detectado en el microservicio");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment