Skip to content

Instantly share code, notes, and snippets.

@dclobato
Created March 19, 2021 19:13
Show Gist options
  • Save dclobato/c9b24aa5049f1dbe972341045f77d358 to your computer and use it in GitHub Desktop.
Save dclobato/c9b24aa5049f1dbe972341045f77d358 to your computer and use it in GitHub Desktop.
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