NLog adapter

NLog is a flexible and free logging platform for various .NET platforms.

KissLog provides NLog integration, which allows developers to save NLog messages to KissLog.net cloud.

Before starting, please make sure that KissLog has been installed by following the Install Instructions.

Steps

1. Install NuGet Package

Install NuGet package KissLog.Adapters.NLog

PM> Install-Package KissLog.Adapters.NLog

2. Update NLog.config

<nlog>
  <extensions>
    <add assembly="KissLog.Adapters.NLog"/>
  </extensions>

  <targets>
    <target name="kisslog" type="KissLog" layout="${message}" />
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="kisslog" />
  </rules>
</nlog>

3. Testing integration

At this point, all the log messages captured by NLog.ILogger logger will be also sent to all KissLog logs output.

namespace Samples.NLogAdapter.Controllers
{
    public class HomeController : Controller
    {
        private readonly NLog.ILogger _logger;
        public HomeController()
        {
            _logger = NLog.LogManager.GetCurrentClassLogger();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            _logger.Debug("Hello world from NLog!");

            System.Threading.Thread.Sleep(300);

            _logger.Info(new { Id = 10, Price = 100.4M, Name = "Product 1" });

            return View();
        }
    }
}

NLog on KissLog cloud