Ejemplo n.º 1
0
        public void Log(LogLevel logLevel, EventId eventId, string details, string userId)
        {
            var dbLogEvent = new DbLogEvent
            {
                Category   = Category,
                ResourceId = ResourceId,
                LogLevel   = logLevel,
                Created    = DateTime.Now,
                Message    = details,
                EventCode  = eventId.Id,
                EventName  = eventId.Name,
                UserId     = userId
            };

            using (var db = new DbLogContext(_db))
            {
                db.Events.Add(dbLogEvent);
                db.SaveChanges();
            }

            if (IncludeConsole)
            {
                Console.WriteLine(details);
            }
        }
Ejemplo n.º 2
0
 public DbLogService(DbLogContext dbLogContext, DbLoggerProvider logProvider)
 {
     _dbLogContext = dbLogContext;
     _logger       = logProvider.CreateLogger(_defaultCategory, null);
 }