| 123456789101112131415161718192021222324252627282930313233343536373839404142 | 
							- using Microsoft.Extensions.Logging;
 
- using System;
 
- namespace DBHelper
 
- {
 
-     public class EFLoggerProvider : ILoggerProvider
 
-     {
 
-         public ILogger CreateLogger(string categoryName) => new EFLogger(categoryName);
 
-         public void Dispose()
 
-         { }
 
-     }
 
-     public class EFLogger : ILogger
 
-     {
 
-         private readonly string categoryName;
 
-         public EFLogger(string categoryName) => this.categoryName = categoryName;
 
-         public bool IsEnabled(LogLevel logLevel) => true;
 
-         public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
 
-         {
 
-             //ef core执行数据库查询时的categoryName为Microsoft.EntityFrameworkCore.Database.Command,日志级别为Information
 
-             if (categoryName == "Microsoft.EntityFrameworkCore.Database.Command"
 
-                     && logLevel == LogLevel.Information)
 
-             {
 
-                 var logContent = formatter(state, exception);
 
-                 if (logContent.Contains("SRM5") || logContent.Contains("STATION5") || logContent.Contains("RGV5") || logContent.Contains("BCR8")) return;
 
-                 DbLog.DBEX(logContent);
 
-                 //TODO: 拿到日志内容想怎么玩就怎么玩吧
 
-                 //Console.WriteLine();
 
-                 //Console.ForegroundColor = ConsoleColor.Green;
 
-                 //Console.WriteLine(logContent);
 
-                 //Console.ResetColor();
 
-             }
 
-         }
 
-         public IDisposable BeginScope<TState>(TState state) => null;
 
-     }
 
- }
 
 
  |