Blog Of Sem: EXCEPTION WRITE TO LOG

EXCEPTION WRITE TO LOG

public void WRITELOG(string ERROR, Exception E, int TYPE)
 {
     try
     {
         string directory = AppDomain.CurrentDomain.BaseDirectory + "logs\\";
         Directory.CreateDirectory(directory);
         string EXTENTION = "";
         if (TYPE == 0)
             EXTENTION = " - ERRORS";
         else if (TYPE == 1)
             EXTENTION = " - STATUS";
         else if (TYPE == 2)
             EXTENTION = " - EXPS";
         string path = directory + DateTime.Now.ToString("yyyy.MM.dd" + EXTENTION) + ".txt";
         if (!File.Exists(path))
             File.Create(path).Close();
         else
         {
             if (TYPE > 0 || E == null)
                 File.AppendAllText(path, Environment.NewLine);
             else
                 File.AppendAllText(path, Environment.NewLine + Environment.NewLine +
                     Environment.NewLine + Environment.NewLine + Environment.NewLine);
         }
         File.AppendAllText(path, DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss"+ " : " + ERROR +
             Environment.NewLine + (E != null ? " ----- HATA : ----- " + E.ToString() : ""));
     }
     catch { }
 }