Esempio n. 1
0
        public static void OnLogEventOccurred(string message, LogEvent.Severity severity)
        {
            EventHandler<EventArgs<LogEvent>> handler = LogEvent;

            if (handler != null)
            {
                handler(
                    null,
                    new EventArgs<LogEvent>(
                        new LogEvent()
                        {
                            LogSeverity = severity,
                            Message = message,
                            Timestamp = DateTime.Now,
                        }));
            }
        }
Esempio n. 2
0
        private void LogNewEvent(LogEvent newEvent)
        {
            if (!dispatcher.CheckAccess())
            {
                dispatcher.BeginInvoke(
                    new Action(
                        delegate
                        {
                            LogNewEvent(newEvent);
                        }
                    ));
            }
            else
            {
                if (newEvent.LogSeverity != LogEvent.Severity.Trace)
                    LogEvents.Add(newEvent);

                ////Add to nLog
                //switch (newEvent.LogSeverity)
                //{
                //    case LogEvent.Severity.Error:
                //        logger.Error(newEvent.Message);
                //        break;
                //    case LogEvent.Severity.Info:
                //        logger.Info(newEvent.Message);
                //        break;
                //    case LogEvent.Severity.Warning:
                //        logger.Warn(newEvent.Message);
                //        break;
                //    case LogEvent.Severity.Trace:
                //        logger.Trace(newEvent.Message);
                //        break;
                //}

            }
        }