Output text to log file

The following method can be used save string messages out to log files.  In the code below I am using a couple class fields to establish the log file name.  These can be customized to meet your need.


public void Output(string message) {
        if (_logFilePath != stringEmpty) {
        string fileName = "LogFile";
        if (_contentDatabaseName != string.Empty)
            fileName += "_" + _contentDatabaseName;

        fileName += ".txt";
        string filePath = System.IO.Path.Combine(_logFilePath, fileName);
        System.IO.StreamWriter sw = System.IO.File.AppendText(filePath); // Change filename
        try {
            string logLine = System.String.Format("{0:G}: {1}.", System.DateTime.Now, message);
        } finally {

Cool eh?



comments powered by Disqus


Recent Tweets

Maybe resolved itself, after resetting emulator and couple vs.net restarts - will let you know
@MillerMark A few weeks ago you tweeted that something huge/incredible was coming....what is/was it? (I am hoping s… twitter.com/i/web/status/9…
Oddly, it won't hit breakpoints in XF .net standard 2 project now either
@JamesMontemagno Updated to 15.7 preview 2 Visual Studio - now having lots of odd thread issues when starting debug… twitter.com/i/web/status/9…