Logging to Note Pad
public static class BFLLogger
{
public static void Log(String Message, bool isException)
{
if (isException)
{
Log(Message);
}
else if (ConfigurationManager.AppSettings["isDebug"].ToString().ToLower() == "true")
{
Log(Message);
}
}
private static void Log(String Message)
{
FileStream fs = new FileStream(ConfigurationManager.AppSettings["BFLTempFolder"].ToString() + "CommonWebService" + DateTime.Now.Day + "_" + DateTime.Now.Month + "_" + DateTime.Now.Year + ".log", FileMode.Append);
StreamWriter w = new StreamWriter(fs, Encoding.UTF8);
w.WriteLine("[" + DateTime.Now.ToString() + "] " + Message);
w.Flush();
w.Close();
fs.Close();
}
}
BFLLogger.Log(ex.Message, true);
{
public static void Log(String Message, bool isException)
{
if (isException)
{
Log(Message);
}
else if (ConfigurationManager.AppSettings["isDebug"].ToString().ToLower() == "true")
{
Log(Message);
}
}
private static void Log(String Message)
{
FileStream fs = new FileStream(ConfigurationManager.AppSettings["BFLTempFolder"].ToString() + "CommonWebService" + DateTime.Now.Day + "_" + DateTime.Now.Month + "_" + DateTime.Now.Year + ".log", FileMode.Append);
StreamWriter w = new StreamWriter(fs, Encoding.UTF8);
w.WriteLine("[" + DateTime.Now.ToString() + "] " + Message);
w.Flush();
w.Close();
fs.Close();
}
}
BFLLogger.Log(ex.Message, true);
No comments:
Post a Comment