Missing error handling in Streaming-AJAX-Proxy Log

on our web site, but started to notice errors accessing log.txt file.
I found that the file is created by Log class and doesn't have ability to switch it off and error handling.
I've added reading file name from configuration and try/catch block
  public static class Log
    {
        private static StreamWriter logStream;
        private static object lockObject = new object ();
    public static void WriteLine(string msg)
        {
                      string logFileName = ConfigurationExtensions.GetAppSetting("AjaxStreamingProxy.LogFile" ,"");
                      if (logFileName.IsNullOrEmpty())
                            return;
                      try
                     {
                            if (logStream == null )
                           {
                                   lock (lockObject)
                                  {
                                          if (logStream == null )
                                         {
                           logStream = File.AppendText(Path .Combine(AppDomain.CurrentDomain.BaseDirectory, logFileName));
                                         }
                                  }
                           }
                           logStream.WriteLine(msg);
                     }
                      catch (Exception exc)
                     {
                            string ignoredMsg = String .Format("The error occured while logging {0}, but processing will continue.\n {1} ", exc);
                            LoggerHelper.LogEvent(ignoredMsg, MyCategorySource, TraceEventType .Warning, true);
                     }
        }
posted @ Saturday, October 6, 2012 12:49 PM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)

 
 
 
 
 

Live Comment Preview:

 
«October»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678