public override void Write(object o) { LoggingTestEntities context = new LoggingTestEntities(); CustomLogEntry e = o as CustomLogEntry; CustomLogging.EntityFramework.LogEntry entry = new EntityFramework.LogEntry(); entry.Priority = e.Priority; entry.TimeStamp = e.TimeStamp; entry.Message = e.Message; entry.MyStuff = e.MyStuff; entry.EventId = e.EventId; entry.Severity = e.Severity.ToString(); entry.Title = e.Title; entry.Machine = e.MachineName; entry.AppDomain = e.AppDomainName; entry.ProcessId = e.ProcessId; entry.ProcessName = e.ProcessName; entry.Win32ThreadId = e.Win32ThreadId; entry.ThreadName = e.ManagedThreadName; context.AddToLogEntries(entry); context.SaveChanges(); }
public static void Write(Exception ex) { LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance <LogWriter>(); CustomLogEntry entry = new CustomLogEntry(); entry.Title = "Error"; entry.Categories.Add(Category.General); entry.Priority = Priority.Normal; entry.Message = ex.ToString(); entry.Severity = System.Diagnostics.TraceEventType.Error; writer.Write(entry); }