I am creating a common class called writelog.cs This is to store the common method to call in all my programs (aspx page) After which, whatever error is produced, it will come out to an error log.txt
This is my codes for writelog.cs And i got this error: The name 'Global' does not exist in the current context
/// <summary>
/// Summary description for Writelog
/// </summary>
/// <param name="Desc">Desc</param>
/// <param name="ID">ID</param>
/// <param name="Pg">Program</param>
/// <param name="Msg">System Error Message</param>
public class Writelog
{
public static void WritelogDesc(string Desc, string ID, string Pg, string Msg)
{
StringBuilder SB = new StringBuilder();
string path = Global.getLogFilePath();
SB.Append(DateTime.Now.ToString("dd/MM/yyyy") + " " + DateTime.Now.ToShortTimeString());
SB.Append(" | ");
SB.Append(Desc);
SB.Append(" | ");
SB.Append(ID);
SB.Append(" | ");
SB.Append(Pg);
SB.Append(" | ");
SB.Append(Msg);
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(SB.ToString());
}
}
using (StreamWriter sw = File.AppendText(path))
{
Writelog.WritelogDesc();
sw.WriteLine(SB.ToString());
}
}
}
And here is how i call writelog.cs
Writelog.WritelogDesc();