Hello
I have made an application with asp.net4 and for this issue i want to make a text file that anytime any Exception raised , the Exception message to be written inside the text file.
so i have done something like below, but it doesn't work and infact does not write any thing.
public class EventLogger
{
public static void Log(string Message, LogType Type)
{
string FullFileName = string.Format("{0}-{1}-{2}.log", DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), DateTime.Now.Day.ToString());
string FullPath = string.Format("{0}\\{1}", HttpContext.Current.Server.MapPath("/Log/Log.txt"), FullFileName);
StreamWriter Writer = new StreamWriter(FullFileName, true, System.Text.Encoding.UTF8);
Writer.WriteLine(string.Format("{0} # {1}", Message.Replace("\r\n", "<br />"), Type.ToString()));
Writer.Close();
Writer.Dispose();
}
}
public enum LogType
{
Error = -1,
Warning = 0,
Normal = 1
}
shall i create any text file in the solution ?
i will be thankfull to help me find the problem .