Mi tarea actual: necesito eliminar StackTrace del objeto {Exception} en OutputTemplate
"WriteTo": [ { "Name": "Console", "Args": { "outputTemplate": "[{Timestamp:yyyy:MM:dd hh:mm:ss} {CorrelationId} {Level:u3}] {Message:lj}{NewLine}{Exception}" } }]El objeto de excepción contiene Mensaje Y StackTrace. Necesito eliminar StackTrace. ¿Es posible?
He probado la propiedad personalizada dentro del Enriquecedor personalizado:
public class ExceptionEnricherTest : ILogEventEnricher { public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { if (logEvent.Exception == null) { return; } var logEventProperty = propertyFactory.CreateProperty("ExceptionWithoutStackTrace", logEvent.Exception.Message); logEvent.AddPropertyIfAbsent(logEventProperty); } } public static class LoggingExtensions { public static LoggerConfiguration WithExceptionEnricher( this LoggerEnrichmentConfiguration enrich) { if (enrich == null) throw new ArgumentNullException(nameof(enrich)); return enrich.With<ExceptionEnricherTest>(); } }Ajustes de aplicaciones en este caso:
"Enrich": [ "FromLogContext", "WithCorrelationId", "WithExceptionEnricher" ] "WriteTo": [ { "Name": "Console", "Args": { "outputTemplate": "[{Timestamp:yyyy:MM:dd hh:mm:ss} {CorrelationId} {ClientIp} {Level:u3}] {Message:lj}{NewLine}{ExceptionWithoutStackTrace}" } }]Pero no veo mi propiedad personalizada.