Exemplo n.º 1
0
        private void convertToEvent(List<LogEventProperty> list, LogUserContext logUserContext)
        {
            if (!string.IsNullOrWhiteSpace(logUserContext.AppDomainIdentity))
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "AppDomainIdentity", Value = logUserContext.AppDomainIdentity });
            }
            if (!string.IsNullOrWhiteSpace(logUserContext.DefaultUser))
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "DefaultUser", Value = logUserContext.DefaultUser });
            }
            if (!string.IsNullOrWhiteSpace(logUserContext.EnvUserName))
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "EnvUserName", Value = logUserContext.EnvUserName });
            }
            if (!string.IsNullOrWhiteSpace(logUserContext.HttpUser))
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "HttpUser", Value = logUserContext.HttpUser });
            }
            if (logUserContext.IsInteractive.HasValue)
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "IsInteractive", Value = logUserContext.IsInteractive.Value.ToString() });
            }

            if (!string.IsNullOrWhiteSpace(logUserContext.ThreadPrincipal))
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "ThreadPrincipal", Value = logUserContext.ThreadPrincipal });
            }
            if (!string.IsNullOrWhiteSpace(logUserContext.UserDomain))
            {
                list.Add(new LogEventProperty() { Group = "UserContext", Name = "UserDomain", Value = logUserContext.UserDomain });
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Retrieve HTTP and Thread identity (names, etc)
 /// WARNING: This is an extemely heavy operation and should only be done in extreme cases (e.g. logging exceptions)
 /// </summary>
 /// <returns></returns>
 public IEventBuilder CaptureIdentity()
 {
     _userContext = new LogUserContext();
     return this;
 }