Example #1
0
        public void DoAppend(LoggingEvent loggingEvent)
        {
            var entry = new LogEntry
            {
                Level = loggingEvent.Level.ToString(),
                Name = loggingEvent.LoggerName,
                Message = loggingEvent.RenderedMessage,
                Timestamp = loggingEvent.TimeStamp
            };

            _appendAction(entry);

            // Create log message which will be written into the log file
            var sb = new StringBuilder();

            // Append timestamp
            sb.Append("[");
            sb.Append(loggingEvent.TimeStamp.ToString("yyyy-MM-dd HH:mm.ss"));
            sb.Append("] ");

            // Append level
            sb.Append(loggingEvent.Level.ToString().ToUpper());
            sb.Append(" ");

            // Append name
            sb.Append("(");
            sb.Append(loggingEvent.LoggerName);
            sb.Append(") ");

            // Append message
            sb.AppendLine(loggingEvent.RenderedMessage);

            AppendLine(sb.ToString());
        }
Example #2
0
 public void AddEntry(LogEntry entry)
 {
     _dispatcher.Invoke(() => Entries.Add(entry));
 }