public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     if (_condition(logEvent))
     {
         _wrapped.Enrich(logEvent, propertyFactory);
     }
 }
        /// <summary>
        /// Enrich the log event.
        /// </summary>
        /// <param name="logEvent">The log event to enrich.</param>
        /// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            LogEventProperty property = propertyFactory.CreateProperty(_propertyName, _componentValue);

            logEvent.AddPropertyIfAbsent(property);

            _machineNameEnricher.Enrich(logEvent, propertyFactory);
        }
Esempio n. 3
0
        void Dispatch(LogEvent logEvent)
        {
            // The enricher may be a "safe" aggregate one, but is most commonly bare and so
            // the exception handling from SafeAggregateEnricher is duplicated here.
            try
            {
                _enricher.Enrich(logEvent, _messageTemplateProcessor);
            }
            catch (Exception ex)
            {
                SelfLog.WriteLine("Exception {0} caught while enriching {1} with {2}.", ex, logEvent, _enricher);
            }

            _sink.Emit(logEvent);
        }
Esempio n. 4
0
    public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
    {
        innerEnricher?.Enrich(logEvent, propertyFactory);

        LogEventPropertyValue eventPropertyValue;

        if (logEvent.Properties.TryGetValue(innerPropertyName, out eventPropertyValue))
        {
            var value = (eventPropertyValue as ScalarValue)?.Value as string;
            if (!String.IsNullOrEmpty(value))
            {
                logEvent.AddPropertyIfAbsent(new LogEventProperty(innerPropertyName + "Delimited", new ScalarValue(value + delimiter)));
            }
        }
    }