Created
November 23, 2024 15:27
-
-
Save javierguerrero/8eacb9866a7e5ffc613fbb805d319a86 to your computer and use it in GitHub Desktop.
exception_handling_csharp_chapter7_5.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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