コード例 #1
0
        public override void AddEntry(LogEntry entry)
        {
            LogItems.Add(entry);
            LogEntries.Add(entry.ToString());

            if (_fileError || Configuration.FullPath == string.Empty) return;

            try
            {
                using (var writer = File.AppendText(Configuration.FullPath))
                {
                    writer.WriteLine(Strings.FileLogEntryFormat,
                        entry.TimeStamp,
                        entry.Level.ToString().ToUpper(),
                        entry.Message);

                    if (entry.HasException)
                    {
                        Writer.WriteException(entry.Exception, writer);
                    }
                }
            }
            catch (Exception ex)
            {
                _fileError = true;
                AddEntry(LogLevel.Error, ex, ex.Message);
            }
        }
コード例 #2
0
        public override void AddEntry(LogEntry entry)
        {
            LogItems.Add(entry);
            LogEntries.Add(entry.ToString());

            try
            {
                System.Console.WriteLine(Strings.FileLogEntryFormat, entry.TimeStamp, entry.Level.ToString().ToUpper(),
                    entry.Message);

                if (entry.HasException)
                {
                    Writer.WriteException(entry.Exception, System.Console.Out);
                }
            }
            catch (Exception ex)
            {
                AddEntry(LogLevel.Error, ex, ex.Message);
            }
        }
コード例 #3
0
        public override void AddEntry(LogEntry entry)
        {
            LogItems.Add(entry);
            LogEntries.Add(entry.ToString());

            try
            {
                System.Diagnostics.Trace.WriteLine(
                    string.Format(Strings.TraceLogEntryFormat,
                        entry.TimeStamp,
                        entry.Level.ToString().ToUpper(),
                        entry.Message));

                if (entry.HasException)
                {
                    Writer.WriteException(entry.Exception, System.Diagnostics.Trace.Listeners);
                }
            }
            catch (Exception ex)
            {
                AddEntry(LogLevel.Error, ex, ex.Message);
            }
        }
コード例 #4
0
ファイル: Log.cs プロジェクト: LionFree/Cush
 public abstract void AddEntry(LogEntry entry);