| 123456789101112131415161718192021222324252627282930 |
- using Microsoft.Extensions.Logging;
- using System;
- namespace CustomHostingDemo.Logging
- {
- public class ConsoleLogger : ILogger
- {
- public string Name { get; }
- public ConsoleLogger(string name)
- {
- Name = name;
- }
- public IDisposable BeginScope<TState>(TState state)
- {
- throw new NotImplementedException();
- }
- public bool IsEnabled(LogLevel logLevel)
- {
- return logLevel != LogLevel.None;
- }
- public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
- {
- Console.WriteLine($"[{logLevel}] {formatter(state, exception)}");
- }
- }
- }
|