6

I have the following code to set up logging to database using NLog. I use an Alpha version of NLog.Extension.Logging. Is it possible to let the built-in log framework log to database so I don't need to use NLog?

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    loggerFactory.AddNLog();
    env.ConfigureNLog("nlog.config");

    app.UseApplicationInsightsRequestTelemetry();

    app.UseApplicationInsightsExceptionTelemetry();

    app.UseMvc();
}
Steven
  • 166,672
  • 24
  • 332
  • 435
ca9163d9
  • 27,283
  • 64
  • 210
  • 413

2 Answers2

1

There is a NuGet package for that (DISCLAIMER: I made it): https://www.nuget.org/packages/DLogger.Extensions.Logging

The GitHub repository: https://github.com/SasaCetkovic/DLogger.Extensions.Logging

Saša Ćetković
  • 885
  • 9
  • 21
0

There is a project on Github that is flexible and available for EF Core:

ZNetCS.AspNetCore.Logging.EntityFrameworkCore

It was prepared to use in ASP NET Core application, but it does not contain any references that prevents to use it in plain .NET Core application. Also there is also possibilty to extend base Log class.

afruzan
  • 1,454
  • 19
  • 20