.net Error log Creation

string ts = DateTime.Now.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture);
string appdata_folder = Application.StartupPath.ToString();
StreamWriter logfile = File.AppendText(String.Format(@"{0}\Sample_Log_{1}.log", appdata_folder, ts));
logfile.Write("User successfully Logged In.");
logfile.Flush();
logfile.Close();

       private static String spath;
        private static StreamWriter sLogPath;
 spath = oNode.Attributes.GetNamedItem("Path").Value;
    spath = Path.Combine(spath, DateTime.Now.ToString("dd-MM-yy") + ".txt");
                sLogPath = File.AppendText(spath);
logfile.Write("User successfully Logged In.");
logfile.Flush();
logfile.Close();

Comments