protected override void Append(LoggingEvent loggingEvent) { var newLog = new LogRecord { Level = GetLogLevel(loggingEvent.Level), LogTime = loggingEvent.TimeStamp, Logger = loggingEvent.LoggerName, Thread = loggingEvent.ThreadName, Message = loggingEvent.MessageObject.ToString(), Exception = loggingEvent.GetExceptionString(), ClassName = loggingEvent.LocationInformation.ClassName, FileName = loggingEvent.LocationInformation.FileName, MethodName = loggingEvent.LocationInformation.MethodName, LineNumber = loggingEvent.LocationInformation.LineNumber, CallStack = loggingEvent.LocationInformation.StackFrames.Select(x => x.ToString()) .Aggregate((a, b) => string.Format("{0}{1}{2}", a, Environment.NewLine, b)) }; var repo = new MongoRepository<LogRecord>(); repo.Insert(newLog); }
public void TestInsert() { var newLog = new LogRecord { Level = LogLevel.Warn, Message = "some error message", Logger = "Test.Logger", LogTime = DateTime.Now, Thread = "1", }; Assert.IsTrue(newLog.Id == ObjectId.Empty); var stopwatch = Stopwatch.StartNew(); mongoRepo.Insert(newLog); stopwatch.Stop(); Assert.IsTrue(newLog.Id != ObjectId.Empty); Console.WriteLine("Insert took : {0}ms", stopwatch.ElapsedMilliseconds); }