protected override void WriteInternal(LogLevel level, object message, Exception exception) { switch (level) { case LogLevel.All: _context.Debug(message.ToString); break; case LogLevel.Debug: _context.Debug(message.ToString); break; case LogLevel.Error: if (exception == null) { _context.Error(message.ToString()); } else { _context.Error(exception, message.ToString()); } break; case LogLevel.Fatal: if (exception == null) { _context.Error(message.ToString()); } else { _context.Error(exception, message.ToString()); } break; case LogLevel.Info: _context.Info(message.ToString()); break; case LogLevel.Off: break; case LogLevel.Trace: _context.Debug(message.ToString); break; case LogLevel.Warn: _context.Warn(message.ToString()); break; } }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { switch (logLevel) { case LogLevel.Debug: _context.Debug(() => formatter(state, exception)); break; case LogLevel.Error: if (exception == null) { _context.Error(formatter(state, exception)); } else { _context.Error(exception, formatter(state, exception)); } break; case LogLevel.Critical: if (exception == null) { _context.Error(formatter(state, exception)); } else { _context.Error(exception, formatter(state, exception)); } break; case LogLevel.Information: _context.Info(formatter(state, exception)); break; case LogLevel.None: break; case LogLevel.Trace: _context.Debug(() => formatter(state, exception)); break; case LogLevel.Warning: _context.Warn(formatter(state, exception)); break; } }