Skip to content

Instantly share code, notes, and snippets.

@oscarkuo
Created September 19, 2016 07:39
Show Gist options
  • Save oscarkuo/7b87d5a28d846ceb9e31a5b437d6f7b0 to your computer and use it in GitHub Desktop.
Save oscarkuo/7b87d5a28d846ceb9e31a5b437d6f7b0 to your computer and use it in GitHub Desktop.
using NLog;
using NLog.Targets;
/*
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="f1" xsi:type="File" fileName="file1.txt"/>
<target name="f2" xsi:type="File" fileName="file2.txt"/>
</targets>
<rules>
<logger name="NLogTest.Test1" minlevel="Trace" writeTo="f1" />
<logger name="*" minlevel="Trace" writeTo="f2" />
</rules>
</nlog>
</configuration>
*/
namespace NLogTest
{
public class Test1
{
public void Call()
{
var log = LogManager.GetCurrentClassLogger();
log.Debug("Hello World => Test 1");
}
}
public class Test2
{
public void Call()
{
LogManager.GetCurrentClassLogger().Debug("Hello World => Test 2");
}
}
class Program
{
static void Main(string[] args)
{
LogManager.ThrowConfigExceptions = true;
new Test1().Call();
new Test2().Call();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment