Пример #1
0
        private static EventLog getEntity(LoggingEventWrap evtw)
        {
            EventLog log = new EventLog();

            log.ID         = Guid.NewGuid().ToString();
            log.AppAgent   = evtw.Evt.UserName;
            log.AppDomain  = evtw.Evt.Domain;
            log.AppID      = App != null ? App.ID : null;
            log.EventLevel = evtw.Evt.Level.Name;
            if (evtw.Evt.ExceptionObject != null)
            {
                log.ExceptionInfo = excpetionToString(evtw.Evt.ExceptionObject);
                //it's important to turn this on for delay loaded properties
                log.IsExceptionInfoLoaded = true;
            }
            log.LoggerName = evtw.Evt.LoggerName;
            TracedLogMessage tmsg = null;

            if (evtw.Evt.MessageObject is TracedLogMessage)
            {
                tmsg            = evtw.Evt.MessageObject as TracedLogMessage;
                log.Message_    = tmsg.Msg;
                log.CallTrackID = tmsg.ID;
            }
            else if (evtw.Evt.MessageObject is string)
            {
                log.Message_ = evtw.Evt.MessageObject as string;
            }
            else
            {
                log.Message_ = evtw.Evt.RenderedMessage;
            }
            log.ThreadName_     = evtw.Evt.ThreadName;
            log.ThreadPrincipal = evtw.Evt.Identity;
            log.TimeStamp_      = evtw.Evt.TimeStamp.Ticks;
            log.Username        = evtw.webUser == null ? evtw.Evt.UserName : evtw.webUser;
            log.PageUrl         = evtw.pageUrl;
            log.ReferringUrl    = evtw.referUrl;
            if (tmsg == null)
            {
                log.CallTrackID = evtw.requestId;
            }
            if (evtw.Evt.Level >= Level.Debug && evtw.Evt.LocationInformation != null && _recordStackFrames)
            {
                log.ChangedEventLocations = new EventLocation[] { getLocation(log.ID, evtw.Evt.LocationInformation) }
            }
            ;
            return(log);
        }
Пример #2
0
        protected override void Append(LoggingEvent evt)
        {
            SetupThread();
            string webUserName = GlobalContext.Properties["user"].ToString();
            string pageUrl     = GlobalContext.Properties["pageUrl"].ToString();
            string referUrl    = GlobalContext.Properties["referUrl"].ToString();
            string requestId   = GlobalContext.Properties["requestId"].ToString();
            var    evtw        = new LoggingEventWrap {
                Evt = evt, webUser = webUserName, pageUrl = pageUrl, referUrl = referUrl, requestId = requestId
            };

            if (!_lossy)
            {
                EventQueue.Add(getEntity(evtw));
            }
            else
            {
                EventQueue.TryAdd(getEntity(evtw));
            }
        }
 private static EventLog getEntity(LoggingEventWrap evtw)
 {
     EventLog log = new EventLog();
     log.ID = Guid.NewGuid().ToString();
     log.AppAgent = evtw.Evt.UserName;
     log.AppDomain = evtw.Evt.Domain;
     log.AppID = App != null ? App.ID : null;
     log.EventLevel = evtw.Evt.Level.Name;
     if (evtw.Evt.ExceptionObject != null)
     {
         log.ExceptionInfo = excpetionToString(evtw.Evt.ExceptionObject);
         //it's important to turn this on for delay loaded properties
         log.IsExceptionInfoLoaded = true;
     }
     log.LoggerName = evtw.Evt.LoggerName;
     TracedLogMessage tmsg = null;
     if (evtw.Evt.MessageObject is TracedLogMessage)
     {
         tmsg = evtw.Evt.MessageObject as TracedLogMessage;
         log.Message_ = tmsg.Msg;
         log.CallTrackID = tmsg.ID;
     }
     else if (evtw.Evt.MessageObject is string)
         log.Message_ = evtw.Evt.MessageObject as string;
     else
         log.Message_ = evtw.Evt.RenderedMessage;
     log.ThreadName_ = evtw.Evt.ThreadName;
     log.ThreadPrincipal = evtw.Evt.Identity;
     log.TimeStamp_ = evtw.Evt.TimeStamp.Ticks;
     log.Username = evtw.webUser == null ? evtw.Evt.UserName : evtw.webUser;
     log.PageUrl = evtw.pageUrl;
     log.ReferringUrl = evtw.referUrl;
     if (tmsg == null)
         log.CallTrackID = evtw.requestId;
     if (evtw.Evt.Level >= Level.Debug &&  evtw.Evt.LocationInformation != null && _recordStackFrames)
         log.ChangedEventLocations = new EventLocation[] { getLocation(log.ID, evtw.Evt.LocationInformation) };
     return log;
 }
 protected override void Append(LoggingEvent[] evts)
 {
     SetupThread();
     foreach (var evt in evts)
     {
         string webUserName = GlobalContext.Properties["user"].ToString();
         string pageUrl = GlobalContext.Properties["pageUrl"].ToString();
         string referUrl = GlobalContext.Properties["referUrl"].ToString();
         string requestId = GlobalContext.Properties["requestId"].ToString();
         var evtw = new LoggingEventWrap { Evt = evt, webUser = webUserName, pageUrl = pageUrl, referUrl = referUrl, requestId = requestId };
         if (!_lossy)
             EventQueue.Add(getEntity(evtw));
         else
             EventQueue.TryAdd(getEntity(evtw));
     } 
 }