void ILogWriter.Write(LogEntry entry) { EventLogEntryType eventLogEntryType; switch (entry.LogLevel) { case LogLevel.Debug: case LogLevel.Trace: case LogLevel.Information: eventLogEntryType = EventLogEntryType.Information; break; case LogLevel.Warning: eventLogEntryType = EventLogEntryType.Warning; break; default: eventLogEntryType = EventLogEntryType.Error; break; } try { var message = TextLogFormatter.Format(entry); _eventLog.WriteEntry(message, eventLogEntryType); } catch (Exception e) { Log.Write(LogLevel.Error, e.ToString()); } }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="encoding"></param> /// <param name="async"></param> /// <param name="bufferSize"></param> /// <param name="timerPeriod"></param> /// <param name="autoFlush"></param> /// <param name="fileAttributes"></param> /// <param name="dateTimeKind"></param> public FileLogWriter( string path, Encoding encoding, bool async, int bufferSize, TimeSpan timerPeriod, bool autoFlush, FileAttributes fileAttributes, DateTimeKind dateTimeKind) { _async = async; ILogFormatter formatter = new TextLogFormatter(); // ILogFormatter formatter = new XmlLogFormatter(); if (async) { _logFile = new AsyncLogFile(path, encoding, bufferSize, timerPeriod, formatter, fileAttributes, dateTimeKind); } else { _logFile = new LogFile(path, encoding, bufferSize, autoFlush, formatter, fileAttributes, dateTimeKind); } }