Created
September 19, 2016 07:39
-
-
Save oscarkuo/7b87d5a28d846ceb9e31a5b437d6f7b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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