Technologies: C#, .NET, Visual Studio 2013

Here is a custom logging class to use in your projects. I know there are packages, but they are overly complex. I needed a simple class that could address logging to a .log file.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace WebDriverIntroduction
{
    public class LogTest
    {
        public void Out(string msg)
        {
            
            StreamWriter sw = File.AppendText("./Test_Output.log");
            try
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(1, true);

                string logLine = String.Format("{0:G}: {1}", DateTime.Now, "Line: " + trace.GetFrame(0).GetFileLineNumber() + ":  " + msg);
                sw.WriteLine(logLine);
            }
            finally
            {
                sw.Close();
            }
        }

    }
}

Resources
n/a