<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Interactive Logic &#187; open source</title>
	<atom:link href="http://interactivelogic.net/wp/tag/open-source/feed/" rel="self" type="application/rss+xml" />
	<link>http://interactivelogic.net/wp</link>
	<description>Evan K. Stone on iOS Development and UX Design and Engineering</description>
	<lastBuildDate>Mon, 09 Apr 2012 16:25:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ASP.NET Logging to the Visual Studio Output Window with log4net</title>
		<link>http://interactivelogic.net/wp/2010/02/aspnet-logging-to-output-window-with-log4net/</link>
		<comments>http://interactivelogic.net/wp/2010/02/aspnet-logging-to-output-window-with-log4net/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 19:14:37 +0000</pubDate>
		<dc:creator>Evan K. Stone</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[annoyances]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://interactivelogic.net/wp/?p=59</guid>
		<description><![CDATA[OK this one has been baffling me for a long time but I just ignored it. We have been using the open source logging library log4net for a long time, and for the most part it was working fine. But the one thing that I wanted to do but could never get working was logging [...]]]></description>
			<content:encoded><![CDATA[<p>OK this one has been baffling me for a long time but I just ignored it. We have been using the open source logging library log4net for a long time, and for the most part it was working fine. But the one thing that I wanted to do but could never get working was logging to what my brain wanted to call &#8220;The Console,&#8221; AKA (to me) the Output window in Visual Studio.</p>
<p>I tried using the log4net appenders ConsoleAppender and ColoredConsoleAppender, to no avail. Turns out there&#8217;s a different appender that works with the Output window, and it&#8217;s not ConsoleAppender.</p>
<p>The appender in question is <a title="TraceAppender - log4net Documentation" href="http://logging.apache.org/log4net/release/sdk/log4net.Appender.TraceAppender.html" target="_blank">TraceAppender</a>!</p>
<p>So here&#8217;s a little snippet of XML from my web.config files that handles output to the Output window (basically the same markup as appears on <a title="TraceAppender - log4net Examples Page" href="http://logging.apache.org/log4net/release/config-examples.html#TraceAppender" target="_blank">the log4net examples page</a>):</p>
<pre>  &lt;/log4net&gt;
    &lt;appender name="TraceAppender" type="log4net.Appender.TraceAppender"&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%d [%t] %-5p %c %m%n"/&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;</pre>
<pre>    &lt;root&gt;
      &lt;level value="ALL"/&gt;
      &lt;appender-ref ref="TraceAppender"/&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;</pre>
<p>To those familiar with the way the log4net section looks in your web.config this will make sense, but the key concept is that, per the log4net documentation, &#8220;Events are written using the System.Diagnostics.Trace.Write(string,string) method&#8221; &#8212; and it turns out that one of the listeners is the Output window!</p>
<p><a title="Nik Boyd - Educery.com" href="http://www.educery.com/" target="_blank">A colleague of mine</a> and I were very confused by all this (I&#8217;m glad I wansn&#8217;t alone in that feeling either!), but we were both very glad to figure this one out.</p>
<p>Thanks go to Google (of course), and <a title="SharpDevelop Forums" href="http://community.sharpdevelop.net/forums/p/4253/12203.aspx" target="_blank">this post</a> on the SharpDevelop forums.</p>
]]></content:encoded>
			<wfw:commentRss>http://interactivelogic.net/wp/2010/02/aspnet-logging-to-output-window-with-log4net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

