Permalink
Browse files

Site updated at 2013-07-11 01:53:06 UTC

  • Loading branch information...
1 parent 9128ea7 commit 0013fd0dec81d72ba2f1afe8126d9f39a3714c1f Nick Miller committed Jul 11, 2013
@@ -4,7 +4,7 @@
<title><![CDATA[Category: .NET, | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/-net-/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: .NET,</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: .NET,</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: .net | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/-net/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: .net</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: .net</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: ASP.NET | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/asp-net/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: ASP.NET</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: ASP.NET</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: c#, | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/c-/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: C#,</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: C#,</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: cheat-sheets | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/cheat-sheets/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: Cheat-sheets</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: Cheat-sheets</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: exocortex | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/exocortex/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -801,6 +801,10 @@ <h1 class="entry-title">Category: Exocortex</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -876,10 +880,6 @@ <h1 class="entry-title">Category: Exocortex</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: howto | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/howto/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -143,6 +143,10 @@ <h1 class="entry-title">Category: Howto</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -218,10 +222,6 @@ <h1 class="entry-title">Category: Howto</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: lightswitch | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/lightswitch/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: Lightswitch</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: Lightswitch</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: linux | Junk I Would Otherwise Forget]]></title>
<link href="nickmiller.com.au/blog/categories/linux/atom.xml" rel="self"/>
<link href="nickmiller.com.au/"/>
- <updated>2013-07-06T15:27:03+10:00</updated>
+ <updated>2013-07-11T11:52:54+10:00</updated>
<id>nickmiller.com.au/</id>
<author>
<name><![CDATA[Nick Miller]]></name>
@@ -101,6 +101,10 @@ <h1 class="entry-title">Category: Linux</h1>
<ul id="recent_posts">
<li class="post">
+ <a href="/blog/2013/07/11/nlog/">Basics of NLog</a>
+ </li>
+
+ <li class="post">
<a href="/blog/2013/07/03/warm-underware/">How to ensure your underware is warm and toasty and ready for you in the morning</a>
</li>
@@ -176,10 +180,6 @@ <h1 class="entry-title">Category: Linux</h1>
<a href="/blog/2012/11/09/path-to-localdb-instances/">Path to localDB instances</a>
</li>
- <li class="post">
- <a href="/blog/2012/11/09/validate-xml-file-against-schema/">Validate XML file against schema</a>
- </li>
-
</ul>
</section>
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+
+ <title><![CDATA[Category: nlog, | Junk I Would Otherwise Forget]]></title>
+ <link href="nickmiller.com.au/blog/categories/nlog-/atom.xml" rel="self"/>
+ <link href="nickmiller.com.au/"/>
+ <updated>2013-07-11T11:52:54+10:00</updated>
+ <id>nickmiller.com.au/</id>
+ <author>
+ <name><![CDATA[Nick Miller]]></name>
+
+ </author>
+ <generator uri="http://octopress.org/">Octopress</generator>
+
+
+ <entry>
+ <title type="html"><![CDATA[Basics of NLog]]></title>
+ <link href="nickmiller.com.au/blog/2013/07/11/nlog/"/>
+ <updated>2013-07-11T11:27:00+10:00</updated>
+ <id>nickmiller.com.au/blog/2013/07/11/nlog</id>
+ <content type="html"><![CDATA[<ul>
+<li>You have a separete logger for each class.</li>
+<li>You instantiate it using LogManager factory and assign it to a private member field.</li>
+</ul>
+
+
+<p>```
+using NLog;</p>
+
+<p>Logger logger = LogManager.GetLogger("MyClassName");
+```</p>
+
+<p>To log things other than exceptions:</p>
+
+<p>```csharp
+using NLog;</p>
+
+<p>public class MyClass
+{
+ private static Logger logger = LogManager.GetCurrentClassLogger();</p>
+
+<p> public void MyMethod1()
+ {</p>
+
+<pre><code>logger.Trace("Sample trace message");
+logger.Debug("Sample debug message");
+logger.Info("Sample informational message");
+logger.Warn("Sample warning message");
+logger.Error("Sample error message");
+logger.Fatal("Sample fatal error message");
+
+// alternatively you can call the Log() method
+// and pass log level as the parameter.
+logger.Log(LogLevel.Info, "Sample fatal error message");
+</code></pre>
+
+<p> }
+}
+```</p>
+
+<p>In NLog.config:</p>
+
+<p>```XML
+&lt;?xml version="1.0" encoding="utf-8" ?>
+&lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"</p>
+
+<pre><code> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+
+&lt;targets&gt;
+ &lt;target name="logfile" xsi:type="File" fileName="file.txt" /&gt;
+&lt;/targets&gt;
+
+&lt;rules&gt;
+ &lt;logger name="*" minlevel="Info" writeTo="logfile" /&gt;
+&lt;/rules&gt;
+</code></pre>
+
+<p></nlog>
+```</p>
+
+<p>For exceptions:</p>
+
+<p>```csharp
+try
+{</p>
+
+<pre><code>// some code which may throw
+</code></pre>
+
+<p>}
+catch (MyException ex)
+{</p>
+
+<pre><code>logger.ErrorException("Got exception.", ex);
+</code></pre>
+
+<p>}
+```</p>
+
+<p>```xml
+<nlog>
+ <targets></p>
+
+<pre><code>&lt;target name="f" type="File"
+ layout="${longdate} ${message} ${exception:format=tostring}"/&gt;
+</code></pre>
+
+<p> </targets>
+ <rules></p>
+
+<pre><code>&lt;logger name="*" writeTo="f"/&gt;
+</code></pre>
+
+<p> </rules>
+</nlog>
+```</p>
+]]></content>
+ </entry>
+
+</feed>
Oops, something went wrong. Retry.

0 comments on commit 0013fd0

Please sign in to comment.