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();
}
6
  • Do you mean that you don't want have a reference to NLog at all? Or that you don't want to have to write logging code inside of each controller to log errors? Commented Sep 12, 2016 at 22:34
  • I don't want to have a reference to NLog since there is no stable library for it. Commented Sep 13, 2016 at 15:49
  • Ahh, okay. There's no built-in library for database logging to my knowledge. You could create your own fairly easily, though. Commented Sep 13, 2016 at 23:36
  • If you are not stuck to NLog you could go with Serilog. Microsoft wrote an extension that plus it directly into aspnet core and they have a sink for writing to a database. Commented Sep 14, 2016 at 3:02
  • how did you solve this? Commented Dec 27, 2020 at 8:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.