<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C# on Bhargava Mummadireddy</title><link>/tags/c%23/</link><description>Recent content in C# on Bhargava Mummadireddy</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>kishoreinvits[at]gmail[dot]com (Bhargava Mummadireddy)</managingEditor><webMaster>kishoreinvits[at]gmail[dot]com (Bhargava Mummadireddy)</webMaster><lastBuildDate>Sun, 16 Feb 2020 23:00:00 +0000</lastBuildDate><atom:link href="/tags/c%23/" rel="self" type="application/rss+xml"/><item><title>How can I easily log a message to a file in c#</title><link>/post/dev/how-can-i-easily-log-a-message-to-a-file-for-debugging-in-c/</link><pubDate>Sun, 16 Feb 2020 23:00:00 +0000</pubDate><author>kishoreinvits[at]gmail[dot]com (Bhargava Mummadireddy)</author><guid>/post/dev/how-can-i-easily-log-a-message-to-a-file-for-debugging-in-c/</guid><description>&lt;p&gt;When you want to write some text to a log file for quick debugging, you can use&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;System.IO.File.AppendAllText(@&amp;quot;D:\Temp\WriteLines.txt&amp;quot;,
string.Concat(&amp;quot;\n&amp;quot;, DateTime.Now, &amp;quot;Your message here&amp;quot;,
this.GetType().Name, &amp;quot;:&amp;quot;,
System.Reflection.MethodBase.GetCurrentMethod().Name));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will have Datetime, Class and method names with your log message. Your file will be created if not exist and new log messages will be appended. Have fun finding that pesky event causing bug you are trying to solve!&lt;/p&gt;</description></item></channel></rss>