/// <summary>
        /// Adds the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> to the logger enrichment configuration which adds the custom <typeparamref name="TCorrelationInfo"/> information from the current context.
        /// </summary>
        /// <typeparam name="TCorrelationInfo">The type of the custom <see cref="CorrelationInfo"/> model.</typeparam>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="correlationInfoEnricher">The custom correlation enricher implementation for the <typeparamref name="TCorrelationInfo"/> model.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or the <paramref name="correlationInfoEnricher"/> is <c>null</c>.</exception>
        public static LoggerConfiguration WithCorrelationInfo <TCorrelationInfo>(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            CorrelationInfoEnricher <TCorrelationInfo> correlationInfoEnricher)
            where TCorrelationInfo : CorrelationInfo
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the correlation information enricher");
            Guard.NotNull(correlationInfoEnricher, nameof(correlationInfoEnricher), "Requires an correlation enricher to enrich the log events with correlation information");

            return(enrichmentConfiguration.With(correlationInfoEnricher));
        }
 public static LoggerConfiguration WithCorrelationIdHeader(
     this LoggerEnrichmentConfiguration enrichmentConfiguration,
     string headerKey = "x-correlation-id")
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration.With(new CorrelationIdHeaderEnricher(headerKey)));
 }
Example #3
0
        public static LoggerConfiguration CustomerLogEnricher(
            this LoggerEnrichmentConfiguration enrich)
        {
            if (enrich == null)
            {
                throw new ArgumentNullException(nameof(enrich));
            }

            return(enrich.With <CustomLogEnricher>());
        }
 /// <summary>
 /// Enrich log events with a properties from the collection of key/value pairs that provide additional user-defined information about the exception.
 /// </summary>
 /// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
 /// <returns>Configuration object allowing method chaining.</returns>
 public static LoggerConfiguration WithExceptionData(
     this LoggerEnrichmentConfiguration enrichmentConfiguration
     )
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration.With(new ExceptionDataEnricher()));
 }
Example #5
0
        public static LoggerConfiguration WithHttpContextInfo(this LoggerEnrichmentConfiguration enrich,
                                                              IServiceProvider serviceProvider, Action <LogEvent, ILogEventPropertyFactory, HttpContext> enrichAction)
        {
            if (enrich == null)
            {
                throw new ArgumentNullException(nameof(enrich));
            }

            return(enrich.With(new HttpContextEnricher(serviceProvider, enrichAction)));
        }
Example #6
0
        public static LoggerConfiguration WithUtcTimestamp(
            this LoggerEnrichmentConfiguration enrichmentConfiguration)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            return(enrichmentConfiguration.With <UtcTimestampEnricher>());
        }
        /// <summary>
        /// Enrich the logging with cart data.
        /// </summary>
        /// <param name="enrichmentConfiguration">The enrichment configuration.</param>
        /// <returns>The LoggerConfiguration.</returns>
        /// <exception cref="ArgumentNullException">enrichmentConfiguration is null</exception>
        public static LoggerConfiguration WithDefaultCartData(
            this LoggerEnrichmentConfiguration enrichmentConfiguration)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            return(enrichmentConfiguration.With <DefaultCartDataEnricher>());
        }
 public static LoggerConfiguration FromTrackingContext(this LoggerEnrichmentConfiguration enrichmentConfiguration)
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration
            .With <TrackingContextEnricher>()
            .Enrich.WithMachineName());
 }
        public static LoggerConfiguration WithShortSourceContext(
            this LoggerEnrichmentConfiguration enrich, int maxLength = 80)
        {
            if (enrich == null)
            {
                throw new ArgumentNullException(nameof(enrich));
            }

            return(enrich.With(new ShortSourceContextEnricher(maxLength)));
        }
Example #10
0
        public static LoggerConfiguration WithLogEventHash(
            this LoggerEnrichmentConfiguration enrichmentConfiguration)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            return(enrichmentConfiguration.With <LogEventHashEnricher>());
        }
 /// <summary>
 /// Enrich log events with the controller name for the current MVC action.
 /// </summary>
 /// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
 /// <param name="propertyName">Name of the property to log.</param>
 /// <returns>Configuration object allowing method chaining.</returns>
 public static LoggerConfiguration WithMvcControllerName(
     this LoggerEnrichmentConfiguration enrichmentConfiguration,
     string propertyName = MvcControllerNameEnricher.MvcControllerPropertyName)
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration.With(new MvcControllerNameEnricher(propertyName)));
 }
Example #12
0
        /// <summary>
        /// Adds the <see cref="VersionEnricher"/> to the logger enrichment configuration which adds the current application version retrieved via the given <paramref name="appVersion"/>.
        /// </summary>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="appVersion">The instance to retrieve the current application version.</param>
        /// <param name="propertyName">The name of the property to enrich the log event with the current application version.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="appVersion"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="propertyName"/> is blank.</exception>
        public static LoggerConfiguration WithVersion(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            IAppVersion appVersion,
            string propertyName = VersionEnricher.DefaultPropertyName)
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the version enricher");
            Guard.NotNull(appVersion, nameof(appVersion), "Requires an application version implementation to enrich the log event with the application version");
            Guard.NotNullOrWhitespace(propertyName, nameof(propertyName), "Requires a non-blank property name to enrich the log event with the current runtime version");

            return(enrichmentConfiguration.With(new VersionEnricher(appVersion, propertyName)));
        }
Example #13
0
        public static LoggerConfiguration WithRequestIdHeader(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            string headerKey = "x-request-id")
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            return(enrichmentConfiguration.With((ILogEventEnricher) new RequestIdHeaderEnricher(headerKey)));
        }
Example #14
0
        public static LoggerConfiguration WithEnvironmentVariables(
            this LoggerEnrichmentConfiguration enrichmentConfiguration, Dictionary <string, string> environmentVariableNames)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            EnvironmentVariablesEnricher.Track(environmentVariableNames);
            return(enrichmentConfiguration.With <EnvironmentVariablesEnricher>());
        }
 /// <summary>
 /// Enrich log events with the named Claim Value.
 /// </summary>
 /// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
 /// <param name="claimProperty">The claim property name searched for value to enrich log events.</param>
 /// <param name="logEventProperty">The property name added to enriched log events. Leave null (default) to use the claim property name.</param>
 /// <returns>Configuration object allowing method chaining.</returns>
 public static LoggerConfiguration WithClaimValue(
     this LoggerEnrichmentConfiguration enrichmentConfiguration,
     string claimProperty,
     string logEventProperty = null)
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration.With(new ClaimValueEnricher(claimProperty, logEventProperty)));
 }
Example #16
0
        /// <summary>
        /// Adds the <see cref="ApplicationEnricher"/> to the logger enrichment configuration which adds the given application's <paramref name="componentName"/>.
        /// </summary>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="componentName">The name of the application component.</param>
        /// <param name="propertyName">The name of the property to enrich the log event with the <paramref name="componentName"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="componentName"/> or <paramref name="propertyName"/> is blank.</exception>
        public static LoggerConfiguration WithComponentName(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            string componentName,
            string propertyName = ApplicationEnricher.ComponentName)
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Require an enrichment configuration to add the application component enricher");
            Guard.NotNullOrWhitespace(componentName, nameof(componentName), "Requires a non-blank application component name");
            Guard.NotNullOrWhitespace(propertyName, nameof(propertyName), "Requires a non-blank property name to enrich the log event with the component name");

            return(enrichmentConfiguration.With(new ApplicationEnricher(componentName, propertyName)));
        }
Example #17
0
        /// <summary>
        /// Enrich log events with a trace and transaction id properties containing the
        /// current ids that the Elastic APM .NET Agent generated.
        /// </summary>
        /// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
        /// <returns>Configuration object allowing method chaining.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="enrichmentConfiguration" /> is null.</exception>
        public static LoggerConfiguration WithElasticApmCorrelationInfo(
            this LoggerEnrichmentConfiguration enrichmentConfiguration
            )
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            return(enrichmentConfiguration.With <ElasticApmEnricher>());
        }
 /// <summary>
 /// Enrich log events with the UserName property when available in the HttpContext.
 /// </summary>
 /// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
 /// <param name="anonymousUsername">The anonymous username. Leave null if you do not want to use anonymous user names. By default it is (anonymous).</param>
 /// <param name="noneUsername">The none username. If there is no username to be found, it will output this username. Leave null (default) to ignore non usernames.</param>
 /// <returns>Configuration object allowing method chaining.</returns>
 public static LoggerConfiguration WithUserName(
     this LoggerEnrichmentConfiguration enrichmentConfiguration,
     string anonymousUsername = "******",
     string noneUsername      = null)
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration.With(new UserNameEnricher(anonymousUsername, noneUsername)));
 }
 /// <summary>
 /// 添加键值对扩展属性
 /// </summary>
 /// <param name="source">日志扩展配置</param>
 /// <param name="keyValue">键值对</param>
 public static LoggerConfiguration WithProperty(this LoggerEnrichmentConfiguration source, KeyValuePair <string, object> keyValue)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     if (keyValue.Equals(default(KeyValuePair <string, object>)))
     {
         throw new ArgumentNullException(nameof(keyValue));
     }
     return(source.With(new KeyValueEnricher(keyValue)));
 }
 /// <summary>
 /// 添加环境扩展属性
 /// </summary>
 /// <param name="source">日志扩展配置</param>
 /// <param name="environmentVariable">环境变量</param>
 public static LoggerConfiguration WithEnvironment(this LoggerEnrichmentConfiguration source, string environmentVariable)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     if (string.IsNullOrWhiteSpace(environmentVariable))
     {
         throw new ArgumentNullException(nameof(environmentVariable));
     }
     return(source.With(new EnvironmentEnricher(environmentVariable)));
 }
        /// <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));
        }
        public static LoggerConfiguration WithCorrelationIdEnricher(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            IServiceProvider serviceProvider)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            var enricher = serviceProvider.GetRequiredService <CorrelationIdEnricher>();

            return(enrichmentConfiguration.With(enricher));
        }
        /// <summary>
        /// Add the <see cref="RaygunClientHttpEnricher"/> to the enrichment configuration.
        /// </summary>
        /// <param name="enrich"></param>
        /// <param name="httpContextAccessor">Optional HttpContext accessor that provides access to the current requests HttpContext.</param>
        /// <param name="restrictedToMinimumLevel">Optional <see cref="LogEventLevel"/> to enrich log events. Defaults to LogEventLevel.Error.</param>
        /// <param name="raygunSettings">Optional <see cref="RaygunSettings"/> that is used to apply http data filtering.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static LoggerConfiguration WithHttpDataForRaygun(
            this LoggerEnrichmentConfiguration enrich,
            IHttpContextAccessor httpContextAccessor = null,
            LogEventLevel restrictedToMinimumLevel   = LogEventLevel.Error,
            RaygunSettings raygunSettings            = null)
        {
            if (enrich == null)
            {
                throw new ArgumentNullException(nameof(enrich));
            }

            return(enrich.With(new RaygunClientHttpEnricher(httpContextAccessor ?? new HttpContextAccessor(), restrictedToMinimumLevel, raygunSettings ?? new RaygunSettings())));
        }
Example #24
0
        /// <summary>
        /// Adds the <see cref="VersionEnricher"/> to the logger enrichment configuration which adds the current application version retrieved via the given <paramref name="serviceProvider"/>.
        /// </summary>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="serviceProvider">The instance to retrieve the current application version.</param>
        /// <param name="propertyName">The name of the property to enrich the log event with the current application version.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="serviceProvider"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="propertyName"/> is blank.</exception>
        public static LoggerConfiguration WithVersion(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            IServiceProvider serviceProvider,
            string propertyName = VersionEnricher.DefaultPropertyName)
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the version enricher");
            Guard.NotNull(serviceProvider, nameof(serviceProvider), $"Requires a services provider collection to look for registered '{nameof(IAppVersion)}' implementations");
            Guard.NotNullOrWhitespace(propertyName, nameof(propertyName), "Requires a non-blank property name to enrich the log event with the current runtime version");

            IAppVersion appVersion = serviceProvider.GetService <IAppVersion>() ?? new AssemblyAppVersion();

            return(enrichmentConfiguration.With(new VersionEnricher(appVersion, propertyName)));
        }
Example #25
0
 /// <summary>
 /// Enrich log events with a ExceptionStackTraceHash property containing the hash of exception's stack trace.
 /// </summary>
 /// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
 /// <param name="exceptionStackTraceHashPropertyName">Property name for stack trace of exception.</param>
 /// <param name="includeExceptionFullname">Allow to include exception type fullname to stack trace.</param>
 /// <param name="ignoreGuids">Whether to remove GUIDs from exception's stacktrace</param>
 /// <returns>Configuration object allowing method chaining.</returns>
 public static LoggerConfiguration WithExceptionStackTraceHash(
     this LoggerEnrichmentConfiguration enrichmentConfiguration,
     string exceptionStackTraceHashPropertyName = null,
     bool includeExceptionFullname = false,
     bool ignoreGuids = false
     )
 {
     if (enrichmentConfiguration == null)
     {
         throw new ArgumentNullException(nameof(enrichmentConfiguration));
     }
     return(enrichmentConfiguration.With(new ExceptionStackTraceHashEnricher(exceptionStackTraceHashPropertyName, includeExceptionFullname, ignoreGuids)));
 }
Example #26
0
        /// <summary>
        /// Adds the <see cref="KubernetesEnricher"/> to the logger enrichment configuration which adds Kubernetes information from the environment.
        /// </summary>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="nodeNamePropertyName">The name of the property to enrich the log event with the Kubernetes node name.</param>
        /// <param name="podNamePropertyName">The name of the property to enrich the log event with the Kubernetes pod name.</param>
        /// <param name="namespacePropertyName">The name of the property to enrich the log event with the Kubernetes namespace.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="nodeNamePropertyName"/>, <paramref name="podNamePropertyName"/>, or <paramref name="namespacePropertyName"/> is blank.</exception>
        public static LoggerConfiguration WithKubernetesInfo(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            string nodeNamePropertyName  = ContextProperties.Kubernetes.NodeName,
            string podNamePropertyName   = ContextProperties.Kubernetes.PodName,
            string namespacePropertyName = ContextProperties.Kubernetes.Namespace)
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the Kubernetes enricher");
            Guard.NotNullOrWhitespace(nodeNamePropertyName, nameof(nodeNamePropertyName), "Requires a non-blank property name to enrich the log event with the Kubernetes node name");
            Guard.NotNullOrWhitespace(podNamePropertyName, nameof(podNamePropertyName), "Requires a non-blank property name to enrich the log event with the Kubernetes pod name");
            Guard.NotNullOrWhitespace(namespacePropertyName, nameof(namespacePropertyName), "Requires a non-blank property name to enrich the log event with the Kubernetes namespace name");

            return(enrichmentConfiguration.With(new KubernetesEnricher(nodeNamePropertyName, podNamePropertyName, namespacePropertyName)));
        }
        /// <summary>
        /// Adds the Azure instance id to log events. The instance id is the value taken from
        /// environment variable WEBSITE_INSTANCE_ID. In Azure App Service this contains the
        /// identifier for the VM that the site is running on.
        /// </summary>
        /// <param name="enrichmentConfiguration">Enrichment configuration to complete.</param>
        /// <returns>Logger configuration with this enricher configured.</returns>
        public static LoggerConfiguration WithAzureWebAppsInstanceId(this LoggerEnrichmentConfiguration enrichmentConfiguration)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            var enricher = new EnvironmentVariableEnricher(
                serilogName: "AzureWebAppsInstanceId",
                environmentName: "WEBSITE_INSTANCE_ID",
                defaultValue: "localhost");

            return(enrichmentConfiguration.With(enricher));
        }
        /// <summary>
        /// Adds the Azure slot name to log events. The slot name is the value taken from
        /// environment variable WEBSITE_SLOT_NAME. In Azure App Service this contains the name of
        /// the deployment slot.
        /// </summary>
        /// <param name="enrichmentConfiguration">Enrichment configuration to complete.</param>
        /// <returns>Logger configuration with this enricher configured.</returns>
        // For details see: https://github.com/Azure/azure-webjobs-sdk/issues/1369#issuecomment-335903927
        public static LoggerConfiguration WithAzureWebAppsSlotName(this LoggerEnrichmentConfiguration enrichmentConfiguration)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            var enricher = new EnvironmentVariableEnricher(
                serilogName: "AzureWebAppsSlotName",
                environmentName: "WEBSITE_SLOT_NAME",
                defaultValue: "unknown");

            return(enrichmentConfiguration.With(enricher));
        }
        /// <summary>
        /// Adds the Azure Web Jobs type to log events. The web job type is taken from environment
        /// variable WEBJOBS_TYPE. In Azure App Service this contains the type of the web job
        /// (triggered or continuous).
        /// </summary>
        /// <param name="enrichmentConfiguration">Enrichment configuration to complete.</param>
        /// <returns>Logger configuration with this enricher configured.</returns>
        public static LoggerConfiguration WithWebJobsType(this LoggerEnrichmentConfiguration enrichmentConfiguration)
        {
            if (enrichmentConfiguration == null)
            {
                throw new ArgumentNullException(nameof(enrichmentConfiguration));
            }

            var enricher = new EnvironmentVariableEnricher(
                serilogName: "AzureWebJobsType",
                environmentName: "WEBJOBS_TYPE",
                defaultValue: "NO_WEBJOB");

            return(enrichmentConfiguration.With(enricher));
        }
Example #30
0
        /// <summary>
        /// Adds the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> to the logger enrichment configuration which adds the custom <typeparamref name="TCorrelationInfo"/> information from the current context.
        /// </summary>
        /// <typeparam name="TCorrelationInfo">The type of the custom <see cref="CorrelationInfo"/> model.</typeparam>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="correlationInfoAccessor">The accessor implementation for the <typeparamref name="TCorrelationInfo"/> model.</param>
        /// <param name="operationIdPropertyName">The name of the property to enrich the log event with the correlation operation ID.</param>
        /// <param name="transactionIdPropertyName">The name of the property to enrich the log event with the correlation transaction ID.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="operationIdPropertyName"/> or <paramref name="transactionIdPropertyName"/> is blank.</exception>
        public static LoggerConfiguration WithCorrelationInfo <TCorrelationInfo>(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor,
            string operationIdPropertyName   = ContextProperties.Correlation.OperationId,
            string transactionIdPropertyName = ContextProperties.Correlation.TransactionId)
            where TCorrelationInfo : CorrelationInfo
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the correlation information enricher");
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires an correlation accessor to retrieve the correlation information during the enrichment of the log events");
            Guard.NotNullOrWhitespace(operationIdPropertyName, nameof(operationIdPropertyName), "Requires a property name to enrich the log event with the correlation operation ID");
            Guard.NotNullOrWhitespace(transactionIdPropertyName, nameof(transactionIdPropertyName), "Requires a property name to enrich the log event with the correlation transaction ID");

            return(enrichmentConfiguration.With(new CorrelationInfoEnricher <TCorrelationInfo>(correlationInfoAccessor, operationIdPropertyName, transactionIdPropertyName)));
        }