Created
March 19, 2021 19:13
-
-
Save dclobato/c9b24aa5049f1dbe972341045f77d358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Logging; | |
using System; | |
using System.IO; | |
namespace EFCore_NM | |
{ | |
class MeuLogProvider : ILoggerProvider | |
{ | |
public ILogger CreateLogger(string categoryName) | |
{ | |
return new MeuLog(); | |
} | |
public void Dispose() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
internal class MeuLog : ILogger | |
{ | |
public IDisposable BeginScope<TState>(TState state) | |
{ | |
return null; | |
} | |
public bool IsEnabled(LogLevel logLevel) | |
{ | |
return true; | |
} | |
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) | |
{ | |
File.AppendAllText(@"D:\VisualStudio2019\logs\sql.txt", formatter(state, exception)); | |
Console.WriteLine(formatter(state, exception)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment