Installing Serilog You will need to add the NLog, NLog.Schema and NLog.Config packages. This command will install the required dependencies.

Install-Package NLog.Config

Configuring NLog

Configuring NLog can be done in your application app.config or web.config.

    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
  <nlog throwExceptions="true">
        <layout type="JsonLayout">
          <attribute name="timestamp" layout="${longdate}" />
          <attribute name="logger" layout="${logger}" />
          <attribute name="machinename" layout="${machinename}" />
          <attribute name="threadid" layout="${threadid}" />
          <attribute name="level" layout="${level}"/>
          <attribute name="message" layout="${message}" />
          <attribute name="exception" layout="${exception}" />
      <logger name="*" minlevel="Trace" writeTo="LogitTarget" />

Using NLog

In order to emit log message you can simply call one of the methods on the Logger.

using NLog;

public class MyClass
  private static Logger logger = LogManager.GetCurrentClassLogger();

  public void MyMethod1()
    logger.Info("Sample trace message");

Nlog is a fully featured logging framework and has many other capabilities that are not detailed here, please see the Nlog Documentation for more information.