Hi, I am trying to do some simple error logging (open a file and write the error). My .net class is opening a new log file in a separate folder which already exists (AppErrors/filename-currdate.txt). I have set trust level to full in my web.config. However no logs or log file appears so I don't think anything is happening. Any help will be appreciated. Here's the code I am using Dim path As String = "AppErrors/ErrorLog.txt" If (Not File.Exists(System.Web.HttpContext.Current.Server.MapPath(path))) Then File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close() End If Using w As StreamWriter = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path)) w.WriteLine(Constants.vbCrLf & "Log Entry : ") w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture)) Dim err As String = "Error" w.WriteLine(err) w.WriteLine("__________________________") w.Flush() w.Close() End Using Many thanks, Sari
I know this does not solve you specific question, but I am using ELMAH. http://code.google.com/p/elmah/ It fully integrates into the pipeline and allows you to setup global error logging. Also, you can access the error log via HTTP without having to ftp and downloading error log files.