public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     if (logEvent.Exception != null)
     {
         logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ExceptionDetail", this.DestructureException(logEvent.Exception), true));
     }
 }
Exemplo n.º 2
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     if (logEvent == null) throw new ArgumentNullException("logEvent");
     if (propertyFactory == null) throw new ArgumentNullException("propertyFactory");
     var property = propertyFactory.CreateProperty(_name, _value, _destructureObjects);
     logEvent.AddPropertyIfAbsent(property);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Enrich the log event with the current ASP.NET user name, if User.Identity.IsAuthenticated is true.</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)
        {
            if (logEvent == null) 
                throw new ArgumentNullException("logEvent");

            var userName = _noneUsername;

            if (HttpContext.Current != null)
            {
                var context = new HttpContextWrapper(HttpContext.Current);

                if (context.User != null)
                {
                    if (context.User.Identity == null || context.User.Identity.IsAuthenticated == false)
                    {
                        if (_anonymousUsername != null)
                            userName = _anonymousUsername;
                    }
                    else
                    {
                        userName = context.User.Identity.Name;
                    }
                }
            }

            if (userName == null) 
                return;

            var userNameProperty = new LogEventProperty(UserNamePropertyName, new ScalarValue(userName));
            logEvent.AddPropertyIfAbsent(userNameProperty);
        }
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");
            if (propertyFactory == null) throw new ArgumentNullException("propertyFactory");

            if (HttpContext.Current == null)
                return;

            int requestId;
            var requestIdItem = HttpContext.Current.Items[RequestIdItemName];
            if (requestIdItem == null)
                HttpContext.Current.Items[RequestIdItemName] = requestId = Interlocked.Increment(ref LastRequestId);
            else
                requestId = (int)requestIdItem;

            string sessionId = null;
            if (HttpContext.Current.Session != null)
                sessionId = HttpContext.Current.Session.SessionID;

            logEvent.AddPropertyIfAbsent(
                propertyFactory.CreateProperty(HttpRequestPropertyName,
                new
                {
                    SessionId = sessionId,
                    Id = requestId,
                },
                destructureObjects: true));
        }
Exemplo n.º 5
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var testProperties = TestContext.CurrentContext?.Test.Properties;
            if (testProperties == null) return;
            if (!testProperties.Contains("TestId")) return;

            logEvent.AddOrUpdateProperty(propertyFactory.CreateProperty("TestId", new ScalarValue(testProperties["TestId"])));
        }
Exemplo n.º 6
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var userName = HttpContext.Current == null || HttpContext.Current.User == null || HttpContext.Current.User.Identity == null
                ? "NoUserContext"
                : HttpContext.Current.User.Identity.Name;

            logEvent.AddPropertyIfAbsent(
                propertyFactory.CreateProperty("UserName", userName));
        }
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     var rnd = new Random();
     int fakeTenantId = rnd.Next(1, 20);
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("RequestId", Guid.NewGuid().ToString("N")));
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("TenantId", fakeTenantId));
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("UserId", "Annonymous Koala"));
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("Version", "1.0")); // in real life, you would get this from the DLL
 }
Exemplo n.º 8
0
        /// <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)
        {
#if !ASPNETCORE50
            _cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.MachineName);
#else
            _cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.GetEnvironmentVariable("COMPUTERNAME"));
#endif
            logEvent.AddPropertyIfAbsent(_cachedProperty);
        }
Exemplo n.º 9
0
 /// <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)
 {
     if (logEvent == null) throw new ArgumentNullException("logEvent");
     if (propertyFactory == null) throw new ArgumentNullException("propertyFactory");
     foreach (var property in _properties)
     {
         logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(property.Key,
                                                                     property.Value,
                                                                     _destructureObjects));
     }
 }
Exemplo n.º 10
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory factory)
        {
            var messageContext = MessageContext.Current;
            if (messageContext == null) return;

            var correlationid = messageContext
                .TransportMessage.Headers
                .GetValueOrNull(Headers.CorrelationId);

            if (correlationid == null) return;

            logEvent.AddOrUpdateProperty(factory.CreateProperty(_propertyName, correlationid));
        }
        /// <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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContextCurrent.Request == null)
                return;

            if (string.IsNullOrWhiteSpace(HttpContextCurrent.Request.UserHostName))
                return;
            
            var userHostName = HttpContextCurrent.Request.UserHostName;
            var httpRequestClientHostnameProperty = new LogEventProperty(HttpRequestClientHostNamePropertyName, new ScalarValue(userHostName));
            logEvent.AddPropertyIfAbsent(httpRequestClientHostnameProperty);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Enrich the log event with an id assigned to the currently-executing HTTP request, if any.
        /// </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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            var serviceProvider = (IServiceProvider)HttpContext.Current;
            var workerReqest = (HttpWorkerRequest)serviceProvider.GetService(typeof(HttpWorkerRequest));
            var requestId = workerReqest.RequestTraceIdentifier;

            var requestIdProperty = new LogEventProperty(HttpRequestTraceIdPropertyName, new ScalarValue(requestId));
            logEvent.AddPropertyIfAbsent(requestIdProperty);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Enrich the log event with the current ASP.NET session id, if sessions are enabled.</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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            if (HttpContext.Current.Session == null)
                return;

            var sessionId = HttpContext.Current.Session.SessionID;
            var sesionIdProperty = new LogEventProperty(HttpSessionIdPropertyName, new ScalarValue(sessionId));
            logEvent.AddPropertyIfAbsent(sesionIdProperty);
        }
Exemplo n.º 14
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     foreach (var enricher in _enrichers)
     {
         try
         {
             enricher.Enrich(logEvent, propertyFactory);
         }
         catch (Exception ex)
         {
             SelfLog.WriteLine("Exception {0} caught while enriching {1} with {2}.", ex, logEvent, enricher);
         }
     }
 }
Exemplo n.º 15
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            try
            {
                var testName = TestContext.CurrentContext?.Test.FullName;
                if (testName == null) return;

                logEvent.AddOrUpdateProperty(propertyFactory.CreateProperty("TestName", new ScalarValue(testName)));
            }
            catch
            {
                // NUnit throws internal NullReferenceExceptions sometimes when we try to fetch
                // the test details :(
            }
        }
Exemplo n.º 16
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            const string prefix = "NimbusMessage.";

            var message = DispatchLoggingContext.NimbusMessage;
            if (message == null) return;

            logEvent.AddOrUpdateProperty(propertyFactory.CreateProperty($"{prefix}MessageType", message.Payload?.GetType().FullName));
            foreach (var property in typeof (NimbusMessage).GetProperties())
            {
                if (property.Name == nameof(NimbusMessage.Payload)) continue;

                logEvent.AddOrUpdateProperty(propertyFactory.CreateProperty($"{prefix}{property.Name}", property.GetValue(message)));
            }
        }
Exemplo n.º 17
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     for (var scope = CurrentScope; scope != null; scope = scope.Parent)
     {
         var stateStructure = scope.State as ILogValues;
         if (stateStructure != null)
         {
             foreach (var keyValue in stateStructure.GetValues())
             {
                 var property = propertyFactory.CreateProperty(keyValue.Key, keyValue.Value);
                 logEvent.AddPropertyIfAbsent(property);
             }
         }
     }
 }
Exemplo n.º 18
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var experiment = string.Empty;
            try
            {
                experiment = ExperimentManager.GetCurrentExperiment();
            }
            catch (Exception e)
            {
                experiment = "Failed: " + e.Message;
            }

            logEvent.AddPropertyIfAbsent(
                propertyFactory.CreateProperty("Experiment", experiment));
        }
Exemplo n.º 19
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory factory)
        {
            var trace = new StackTrace();
            const int index = 5;
            if (trace.FrameCount < index)
            {
                logEvent.RemovePropertyIfPresent("ClassName");
                logEvent.RemovePropertyIfPresent("MethodName");
                return;
            }

            var method = trace.GetFrame(index).GetMethod();

            logEvent.AddOrUpdateProperty(factory.CreateProperty("ClassName", method.ReflectedType));
            logEvent.AddOrUpdateProperty(factory.CreateProperty("MethodName", method.ToString()));
        }
Exemplo n.º 20
0
        /// <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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            if (HttpContextCurrent.Request == null)
                return;

            if (string.IsNullOrWhiteSpace(HttpContextCurrent.Request.RawUrl))
                return;

            var requestRawUrl = HttpContextCurrent.Request.RawUrl;
            var httpRequestRawUrlProperty = new LogEventProperty(HttpRequestRawUrlPropertyName, new ScalarValue(requestRawUrl));
            logEvent.AddPropertyIfAbsent(httpRequestRawUrlProperty);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Enrich the log event with the number assigned to the currently-executing HTTP request, if any.
        /// </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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            int requestNumber;
            var requestNumberItem = HttpContext.Current.Items[RequestNumberItemName];
            if (requestNumberItem == null)
                HttpContext.Current.Items[RequestNumberItemName] = requestNumber = Interlocked.Increment(ref LastRequestNumber);
            else
                requestNumber = (int)requestNumberItem;

            var requestNumberProperty = new LogEventProperty(HttpRequestNumberPropertyName, new ScalarValue(requestNumber));
            logEvent.AddPropertyIfAbsent(requestNumberProperty);
        }
Exemplo n.º 22
0
        /// <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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            if (HttpContextCurrent.Request == null)
                return;

            if (HttpContextCurrent.Request.UrlReferrer == null)
                return;

            var requestUrlReferrer = HttpContextCurrent.Request.UrlReferrer.ToString();
            var httpRequestUrlReferrerProperty = new LogEventProperty(HttpRequestUrlReferrerPropertyName, new ScalarValue(requestUrlReferrer));
            logEvent.AddPropertyIfAbsent(httpRequestUrlReferrerProperty);
        }
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            if (logEvent == null)
                throw new ArgumentNullException("logEvent");

            if (logEvent.Exception != null)
            {
                var exceptionType = logEvent.Exception.GetType();

                var nestedProperties = exceptionType.GetProperties().Select(
                    x => CreateLogProperty(x.Name, x.GetValue(logEvent.Exception, null))).ToList();
                nestedProperties.Add(CreateLogProperty("Type", exceptionType));

                logEvent.AddOrUpdateProperty(
                    new LogEventProperty(ExceptionPropertyName, new DictionaryValue(nestedProperties)));
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Enrich the log event with an id assigned to the currently-executing HTTP request, if any.
        /// </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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            Guid requestId;
            var requestIdItem = HttpContext.Current.Items[RequestIdItemName];
            if (requestIdItem == null)
                HttpContext.Current.Items[RequestIdItemName] = requestId = Guid.NewGuid();
            else
                requestId = (Guid)requestIdItem;

            var requestIdProperty = new LogEventProperty(HttpRequestIdPropertyName, new ScalarValue(requestId));
            logEvent.AddPropertyIfAbsent(requestIdProperty);
        }
Exemplo n.º 25
0
        /// <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)
        {
            var properties = new List<LogEventProperty>
            {
                _cachedProperties.GetOrAdd("MachineName",
                    k => propertyFactory.CreateProperty(k, Environment.MachineName)),
                _cachedProperties.GetOrAdd("Is64BitOperatingSystem",
                    k => propertyFactory.CreateProperty(k, Environment.Is64BitOperatingSystem)),
                _cachedProperties.GetOrAdd("OSVersion", k => propertyFactory.CreateProperty(k, Environment.OSVersion)),
                _cachedProperties.GetOrAdd("ProcessorCount",
                    k => propertyFactory.CreateProperty(k, Environment.ProcessorCount)),
                _cachedProperties.GetOrAdd(".NETVersion", k => propertyFactory.CreateProperty(k, Environment.Version))
            };

            foreach (var p in properties)
            {
                logEvent.AddPropertyIfAbsent(p);
            }
        }
Exemplo n.º 26
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var frames = new StackTrace().GetFrames();
            Func<StackFrame, bool> serilogFrames =
                stack =>
                    stack.GetMethod()
                        .DeclaringType
                        .Namespace
                        .StartsWith("serilog.core", StringComparison.InvariantCultureIgnoreCase);
            var serilogFrameCount = frames.Count(serilogFrames);
            var callerFrame = frames.Skip(serilogFrameCount + 1).First();

            var method = callerFrame.GetMethod().Name;
            var caller = callerFrame.GetMethod().DeclaringType.FullName;

            var property = propertyFactory.CreateProperty("LogCaller",
                new LogCaller {ClassName = caller, Method = method});
            logEvent.AddOrUpdateProperty(property);
        }
        /// <summary>
        /// Enriches the log event.
        /// </summary>
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            if (logEvent.Exception == null)
                return;

            var readableStackTrace = propertyFactory.CreateProperty(
                "ReadableStackTrace",
                logEvent.Exception.ToAsyncString(),
                destructureObjects: true);

            logEvent.AddPropertyIfAbsent(readableStackTrace);

            var fullExceptionString = propertyFactory.CreateProperty(
                "FullExceptionString",
                logEvent.Exception.ToString(),
                destructureObjects: true);

            logEvent.AddPropertyIfAbsent(fullExceptionString);
        }
        /// <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)
        {
            if (logEvent == null) throw new ArgumentNullException("logEvent");

            if (HttpContext.Current == null)
                return;

            if (HttpContextCurrent.Request == null)
                return;

            if (string.IsNullOrWhiteSpace(HttpContextCurrent.Request.UserHostAddress))
                return;

            string userHostAddress;

            // Taking Proxy/-ies into consideration, too (if wanted and available)
            if (CheckForHttpProxies)
            {
                userHostAddress = !string.IsNullOrWhiteSpace(HttpContextCurrent.Request.ServerVariables["HTTP_X_FORWARDED_FOR"])
                ? HttpContextCurrent.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
                : HttpContextCurrent.Request.UserHostAddress;
            }
            else
            {
                userHostAddress = HttpContextCurrent.Request.UserHostAddress;
            }

            if (string.IsNullOrWhiteSpace(userHostAddress))
                return;

            // As multiple proxies can be in place according to header spec (see http://en.wikipedia.org/wiki/X-Forwarded-For), we check for it and only extract the first address (which 'should' be the actual client one)
            if (userHostAddress.Contains(","))
            {
                userHostAddress = userHostAddress.Split(',').First().Trim();
            }

            var httpRequestClientHostIPProperty = new LogEventProperty(HttpRequestClientHostIPPropertyName, new ScalarValue(userHostAddress));
            logEvent.AddPropertyIfAbsent(httpRequestClientHostIPProperty);
        }
Exemplo n.º 29
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("Component", "global"));
 }
Exemplo n.º 30
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory pf)
 {
     logEvent.AddOrUpdateProperty(pf.CreateProperty("MachineName", Environment.MachineName));
     logEvent.AddOrUpdateProperty(pf.CreateProperty("ProcessName", Process.GetCurrentProcess().ProcessName));
     logEvent.AddOrUpdateProperty(pf.CreateProperty("ThreadId", Thread.CurrentThread.ManagedThreadId));
 }
Exemplo n.º 31
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
 }
Exemplo n.º 32
0
 private static LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory, string key, object value)
 {
     return(propertyFactory.CreateProperty(key, value));
 }
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory lepf)
 {
     logEvent.AddPropertyIfAbsent(lepf.CreateProperty("UtcTimestamp", logEvent.Timestamp.UtcDateTime));
 }
Exemplo n.º 34
0
 /// <summary>
 /// Enriches a given log event with data from the current <see cref="OperationContext"/>.
 /// </summary>
 /// <param name="logEvent">The log event to enrich.</param>
 /// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
 internal static void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     OperationLogContext.EnrichLogEvent(logEvent, propertyFactory);
 }
Exemplo n.º 35
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     _cachedEventProperty = _cachedEventProperty ?? propertyFactory.CreateProperty(ServiceNamePropertyName, _serviceName);
     logEvent.AddPropertyIfAbsent(_cachedEventProperty);
 }
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddOrUpdateProperty(new LogEventProperty("Context", new ScalarValue($"OutboxMessage:{_notification.Id.ToString()}")));
 }
Exemplo n.º 37
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(
         propertyFactory.CreateProperty(LogEventPropertyKeys.Id, IdGenerator.Instance.Next));
 }
Exemplo n.º 38
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("Pool", "-"));
 }
Exemplo n.º 39
0
        // public ContextEnricher(Context context)
        // {
        //     _context = context ?? throw new ArgumentNullException(nameof(context));
        // }

        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("_context", _context, destructureObjects: true));
        }
Exemplo n.º 40
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory _)
 {
     Events.Add(logEvent);
 }
Exemplo n.º 41
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddOrUpdateProperty(new LogEventProperty("EventId", new ScalarValue(EventIdHash.Compute(logEvent.MessageTemplate.Text))));
 }
Exemplo n.º 42
0
        private static LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
        {
            var value = Environment.GetEnvironmentVariable("RELEASE_NUMBER") ?? "local";

            return(propertyFactory.CreateProperty(PropertyName, value));
        }
Exemplo n.º 43
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(logEvent.Properties.Keys.Contains("SourceContext")
         ? propertyFactory.CreateProperty("Source", logEvent.Properties["SourceContext"].ToString().Replace("\"", "").Split('.').Last())
         : propertyFactory.CreateProperty("Source", "n/a"));
 }
Exemplo n.º 44
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     cachedProperty = cachedProperty ?? propertyFactory.CreateProperty("CustomPropertyName", "CustomPropertyValue");
     logEvent.AddPropertyIfAbsent(cachedProperty);
 }
Exemplo n.º 45
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     _cachedEventProperty = _cachedEventProperty ?? propertyFactory.CreateProperty(EnvironmentStampPropertyName, _environmentName);
     logEvent.AddPropertyIfAbsent(_cachedEventProperty);
 }
Exemplo n.º 46
0
 /// <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)
 {
     _cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.GetEnvironmentVariable("COMPUTERNAME"));
     logEvent.AddPropertyIfAbsent(_cachedProperty);
 }
Exemplo n.º 47
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            LogEventProperty logCode = propertyFactory.CreateProperty("logcode", "1");

            logEvent.AddPropertyIfAbsent(logCode);
        }
Exemplo n.º 48
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("AzureWebAppsName", Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? _defaultAppName));
 }
Exemplo n.º 49
0
 /// <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)
 {
     logEvent.AddPropertyIfAbsent(new LogEventProperty(ThreadIdPropertyName, new ScalarValue(Thread.CurrentThread.ManagedThreadId)));
 }
Exemplo n.º 50
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("LogToSql", true));
 }
Exemplo n.º 51
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("HubName", HubName));
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ServerName", URL));
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("SourceContext", typeof(T).FullName));
 }
Exemplo n.º 52
0
 /// <inheritdoc />
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) =>
 logEvent.AddPropertyIfAbsent(
     propertyFactory.CreateProperty(
         "UtcTimestamp",
         logEvent.Timestamp.UtcDateTime));
Exemplo n.º 53
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var value = Environment.GetEnvironmentVariable("RELEASE_NUMBER") ?? "local";

            logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(PropertyName, value));
        }
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddOrUpdateProperty(new LogEventProperty("Context", new ScalarValue($"Command:{_command.Id.ToString()}")));
 }
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("Username", _user.Username));
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ComputerName", _user.Lab));
 }
 /// <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)
 {
     EnrichEnvironmentVariable(NodeNameVariable, _nodeNamePropertyName, logEvent, propertyFactory);
     EnrichEnvironmentVariable(PodNameVariable, _podNamePropertyName, logEvent, propertyFactory);
     EnrichEnvironmentVariable(NamespaceVariable, _namespacePropertyName, logEvent, propertyFactory);
 }
Exemplo n.º 57
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var projectName = propertyFactory.CreateProperty("ProjectName", ConfigurationTk.InitialAssemblyName);

            logEvent.AddPropertyIfAbsent(projectName);
        }
Exemplo n.º 58
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ThreadId", Thread.CurrentThread.ManagedThreadId));
 }
Exemplo n.º 59
0
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var eventTime = propertyFactory.CreateProperty("EventTime", DateTime.UtcNow);

            logEvent.AddPropertyIfAbsent(eventTime);
        }
        void AddProperty(LogEvent logEvent, ILogEventPropertyFactory propertyFactory, string name, object value)
        {
            var property = propertyFactory.CreateProperty(name, value);

            logEvent.AddPropertyIfAbsent(property);
        }