Beispiel #1
0
        public void Log(LogEntry entry)
        {
            try
            {
                var entryType = GetEntryType(entry.Message.Level);

                StringBuilder mb = new StringBuilder();

                mb.AppendFormat("{0} {1}:", entry.Message.Time, entry.LoggerName).AppendLine();
                mb.AppendLine();
                mb.AppendLine(entry.Message.Message);

                if (entry.Message.StackTrace != null)
                {
                    mb.AppendLine();
                    mb.AppendLine(entry.Message.StackTrace);
                }

                EventLog.WriteEntry(source, mb.ToString(), entryType);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("EventLogAppender.Log exception: " + ex);
            }
        }
Beispiel #2
0
        public void Log(LogEntry entry)
        {
            if (entry.Message.Level < LevelFilter)
                return;

            foreach (var appender in Appenders)
                appender.Log(entry);
        }
Beispiel #3
0
 public void Log(LogEntry le)
 {
     Trace.WriteLine(String.Format("{0:yyyy-MM-dd HH:mm:ss.fff} {1:-10} {2}: {3}", le.Message.Time, le.Message.Level.ToString(), le.LoggerName, le.Message.Message));
     if (le.Message.StackTrace != null)
     {
         Trace.Write("\t\t\t");
         Trace.WriteLine(le.Message.StackTrace);
     }
 }
Beispiel #4
0
        public void Log(LogEntry entry)
        {
            //if (Smtp == null || Smtp.Host == null || From == null)
            //{
            //    Debug.WriteLine("Mail appender not configured properly.");
            //    return;
            //}

            try
            {
                StringBuilder mb = new StringBuilder();

                mb.AppendFormat("{0:yyyy-MM-dd HH:mm:ss.fff} {1}: {2}", entry.Message.Time, entry.Message.Level, entry.LoggerName).AppendLine();
                mb.AppendLine();
                mb.AppendLine(entry.Message.Message);

                if (entry.Message.StackTrace != null)
                {
                    mb.AppendLine();
                    mb.AppendLine(entry.Message.StackTrace);
                }

                var msg = new MailMessage();

                if (!String.IsNullOrWhiteSpace(Bcc))
                    msg.Bcc.Add(PrepareAddresses(Bcc));

                if (!String.IsNullOrWhiteSpace(To))
                    msg.To.Add(PrepareAddresses(To));

                if (!String.IsNullOrEmpty(From))
                    msg.From = new MailAddress(From);

                msg.Body = mb.ToString();

                msg.Subject = Subject;
                if (AppendLogLevelToMessageSubject)
                    msg.Subject += " " + entry.Message.Level.ToString();

                if (SendAsync)
                    ThreadPool.QueueUserWorkItem(Send, msg);
                else
                    Send(msg);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("MailLogAppender.Log exception: " + ex);
                SmtpErrorLogger.Exception("Error occured while sending log entry email.", ex);
            }
        }
Beispiel #5
0
 public void Log(LogEntry entry)
 {
     var a = LogAction;
     if (a != null)
         try
         {
             a(entry);
         }
         catch (Exception ex)
         {
             Debug.WriteLine("DelegateLogAppender error: " + ex.Message);
             Debug.WriteLine(ex.StackTrace);
         }
 }
Beispiel #6
0
 public void Log(LogEntry entry)
 {
 }
Beispiel #7
0
 public void Log(LogEntry entry)
 {
     messageQueue.Add(entry);
 }
Beispiel #8
0
 protected virtual void LogEntry(LogEntry le)
 {
     LogAppender.Log(le);
 }
Beispiel #9
0
        internal void Log(LogMessage lm)
        {
            if (!Enabled)
                return;

            if (lm.Time == default(DateTime))
                lm.Time = DateTime.Now;

            var le = new LogEntry
            {
                Message = lm,
                LoggerName = LogName
            };

            LogEntry(le);

            if (OnLogEntry != null)
                OnLogEntry(this, new LogEntryEventArgs { LogEntry = le });
        }