<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How can I easily log a message to a file for debugging purposes?</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx</link><description>Often, you need a way to monitor your applications once they are running on the server or even at the customer site -- away from your Visual Studio debugger. In those situations, it is often helpful to have a simple routine that you can use to log messages</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: How can I easily log a message to a file for debugging purposes?</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#563100</link><pubDate>Tue, 28 Mar 2006 18:42:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:563100</guid><dc:creator>Paul Fullhouse</dc:creator><description>Shouldn't you be recommending people use the Event Log for this purpose? &amp;nbsp;Developers should create an event message source and use the application log or create a custom event log. &amp;nbsp;Our applications typically implement the System.Configuration.Install.Installer interface in order to add the source to the log.</description></item><item><title>re: How can I easily log a message to a file for debugging purposes?</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#564929</link><pubDate>Thu, 30 Mar 2006 18:39:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:564929</guid><dc:creator>Doogal</dc:creator><description>I've always liked the TraceListener infrastructure, since you can turn them on or off and you can redirect them to the Event Log, text file, debugger output etc. And you can write your own trace listener to log to whatever you like.</description></item><item><title>re: How can I easily log a message to a file for debugging purposes?</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#567888</link><pubDate>Tue, 04 Apr 2006 07:42:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:567888</guid><dc:creator>Jani Järvinen</dc:creator><description>Paul, Doogal: Thank you for your comments. Indeed, there are many ways to support logging in .NET applications, trace listeners and the Windows Event Log being two choices. This FAQ entry was not meant to answer the question, “Which logging method should I choose for my application?”&lt;br&gt;&lt;br&gt;Instead, I wanted to show with a simple and short example of functionality that is often asked by beginning programmers. I also prefer trace listeners, but sometimes one just needs something very simple. As for the Event Log, that is one choice, but often debugging events are highly frequent and verbose, and thus unsuitable to be added to the Event Log.&lt;br&gt;&lt;br&gt;I’m working on further FAQ entries relating debugging, so stay tuned for a more complete picture of logging tips. Thanks!</description></item><item><title>Solutions for basic logging &amp;laquo; # cat blogPosts</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#769933</link><pubDate>Mon, 25 Sep 2006 06:14:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:769933</guid><dc:creator>Solutions for basic logging « # cat blogPosts</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://elevate.wordpress.com/2006/09/25/solutions-for-basic-logging/"&gt;http://elevate.wordpress.com/2006/09/25/solutions-for-basic-logging/&lt;/a&gt;</description></item><item><title>LogFiles in C# erstellen</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#2475878</link><pubDate>Tue, 08 May 2007 10:42:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2475878</guid><dc:creator>Everyone should have at least one Gotchi!</dc:creator><description>&lt;p&gt;Der einfachste Weg, meiner Meinung nach, um ein LogFile f&amp;#252;r ein Applikation in C# zu erstellen: public static void Log(String logMessage) { using (StreamWriter w = File.AppendText(&amp;amp;quot;log.txt&amp;amp;quot;)) { w.Write(&amp;amp;quot;\r\n{0} {1}&amp;amp;qu&lt;/p&gt;
</description></item><item><title>Everyone should have at least one Gotchi!  &amp;raquo; LogFiles in C# erstellen</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#3940402</link><pubDate>Wed, 18 Jul 2007 20:25:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3940402</guid><dc:creator>Everyone should have at least one Gotchi!  » LogFiles in C# erstellen</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blog.gotchi.at/2007/05/08/logfiles-in-c-erstellen/"&gt;http://blog.gotchi.at/2007/05/08/logfiles-in-c-erstellen/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>How can I easily log a message to a file for debugging purposes?</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#8399006</link><pubDate>Wed, 16 Apr 2008 17:07:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8399006</guid><dc:creator>Honest Illusion</dc:creator><description>&lt;p&gt;Today, either Bloglines.com or blogs.MSDN.com blinked, and suddenly I'm seeing old entries on the 'C#&lt;/p&gt;
</description></item><item><title>re: How can I easily log a message to a file for debugging purposes?</title><link>http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx#9923672</link><pubDate>Tue, 17 Nov 2009 16:47:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923672</guid><dc:creator>Slightly cleaner with File.AppendAllText</dc:creator><description>&lt;p&gt;private static readonly string LOG_FILENAME = Path.GetTempPath() + &amp;quot;My Log File.txt&amp;quot;;&lt;/p&gt;
&lt;p&gt;public static void LogMessageToFile(string msg)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;msg = string.Format(&amp;quot;{0:G}: {1}\r\n&amp;quot;, DateTime.Now, msg);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;File.AppendAllText(LOG_FILENAME, msg);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
</description></item></channel></rss>