Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


  1. Thank you for the article, Once I tried the same, I got an error, When I check the NLog internal log, it says I am missing to include SqlClient to connect the database. Then I installed it from NuGet. “Install-Package Microsoft.Data.SqlClient -Version 2.0.1”

    Then everything was nice and easy. Thanks for the well written article

  2. Great post!

    Just a Small tip on an error I got.
    The database fieldname ‘When’ is not the best name for a date field. It’s also a sql command.
    I kept on hitting errors in my insert. in the end I put [When] in , to make sure SQL gets it 🙂

  3. Thank you for the Article. You are really a life saver. I was integrating Nlog with .net core app. And was not able generate the log file. But by reading your I found that I was missing missing the configuration in Program.cs file. Thanks again.

  4. Hello Mukesh, thank you for this tutorial. As all other tutorials are incomplete. This is essential for beginners to have a working (mostly) tutorial.
    There are a few errors in the database logging section:
    (as mentionned in the comments) the ‘when’ field needs to be wrapped in square brackets
    commandText=”INSERT INTO [MyLogs]([When],[Message],[Level],[Exception],[Trace],[Logger]) VALUES (getutcdate(),@msg,@level,@exception,@trace,@logger)”>

    also ${trace} renderer does not exist, or no longer exists. I replaced it with ${stacktrace}.

    Again, big thank you!