<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="logfile" xsi:type="File" fileName="logfile.txt" />
<target name="logconsole" xsi:type="Console" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logconsole" />
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
using NLog;
using System;
namespace LoggingDemo.Nlog
{
class Program
{
static void Main(string[] args)
{
LogManager.LoadConfiguration("nlog.config");
var log = LogManager.GetCurrentClassLogger();
log.Debug("Starting up");
log.Debug("Shutting down");
Console.ReadLine();
}
}
}