Enrich a LogEvent with details about an LogEvent.Exception if present.
상속: ILogEventEnricher
예제 #1
0
        public static Serilog.LoggerConfiguration WithExceptionDetails(
            this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration,
            IEnumerable <IExceptionDestructurer> destructurers)
        {
            ILogEventEnricher enricher = new ExceptionEnricher(new DestructuringOptionsBuilder().WithDestructurers(destructurers));

            return(loggerEnrichmentConfiguration.With(enricher));
        }
예제 #2
0
        /// <summary>
        /// Enrich logger output with a destuctured object containing
        /// exception's public properties.
        /// </summary>
        /// <param name="loggerEnrichmentConfiguration">The enrichment configuration</param>
        /// <param name="destructuringOptions">
        /// Options that will influence the process of destructuring
        /// exception's properties into result object.
        /// </param>
        /// <returns>Configuration object allowing method chaining.</returns>
        public static Serilog.LoggerConfiguration WithExceptionDetails(
            this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration,
            IDestructuringOptions destructuringOptions)
        {
            ILogEventEnricher enricher = new ExceptionEnricher(destructuringOptions);

            return(loggerEnrichmentConfiguration.With(enricher));
        }
예제 #3
0
        /// <summary>
        /// Enrich logger output with a destuctured object containing
        /// exception's public properties. Default destructurers are registered.
        /// <see cref="Exception.StackTrace"/> and <see cref="Exception.TargetSite"/> are omitted
        /// by the destructuring process because Serilog already attaches them to log event.
        /// </summary>
        /// <param name="loggerEnrichmentConfiguration">The enrichment configuration</param>
        /// <returns>Configuration object allowing method chaining.</returns>
        public static Serilog.LoggerConfiguration WithExceptionDetails(
            this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration)
        {
            var options = new DestructuringOptionsBuilder()
                          .WithDefaultDestructurers()
                          .WithIgnoreStackTraceAndTargetSiteExceptionFilter();
            var logEventEnricher = new ExceptionEnricher(options);

            return(loggerEnrichmentConfiguration.With(logEventEnricher));
        }
        /// <summary>
        /// Enrich logger output with a destuctured object containing exception's public properties.
        /// </summary>
        /// <param name="loggerEnrichmentConfiguration">The enrichment configuration.</param>
        /// <param name="destructuringOptions">
        /// Options that will influence the process of destructuring exception's properties into result object.
        /// </param>
        /// <returns>Configuration object allowing method chaining.</returns>
        public static LoggerConfiguration WithExceptionDetails(
            this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration,
            IDestructuringOptions destructuringOptions)
        {
            if (loggerEnrichmentConfiguration is null)
            {
                throw new ArgumentNullException(nameof(loggerEnrichmentConfiguration));
            }

            ILogEventEnricher enricher = new ExceptionEnricher(destructuringOptions);

            return(loggerEnrichmentConfiguration.With(enricher));
        }
        /// <summary>
        /// Enrich logger output with a destuctured object containing exception's public properties. Default
        /// destructurers are registered. <see cref="Exception.StackTrace"/> and Exception.TargetSite
        /// are omitted by the destructuring process because Serilog already attaches them to log event.
        /// </summary>
        /// <param name="loggerEnrichmentConfiguration">The enrichment configuration.</param>
        /// <returns>Configuration object allowing method chaining.</returns>
        public static LoggerConfiguration WithExceptionDetails(
            this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration)
        {
            if (loggerEnrichmentConfiguration is null)
            {
                throw new ArgumentNullException(nameof(loggerEnrichmentConfiguration));
            }

            var options = new DestructuringOptionsBuilder()
                          .WithDefaultDestructurers()
                          .WithIgnoreStackTraceAndTargetSiteExceptionFilter();
            var logEventEnricher = new ExceptionEnricher(options);

            return(loggerEnrichmentConfiguration.With(logEventEnricher));
        }