Exemple #1
0
        private DebugCenter()
        {
            SyslogMaintain.DeleteLog();
            SyslogMaintain.BackupLog();
            string text = AppDomain.CurrentDomain.BaseDirectory;

            if (text[text.Length - 1] != Path.DirectorySeparatorChar)
            {
                text += Path.DirectorySeparatorChar;
            }
            string text2 = text + "debuglog" + Path.DirectorySeparatorChar;

            if (text2[text2.Length - 1] != Path.DirectorySeparatorChar)
            {
                text2 += Path.DirectorySeparatorChar;
            }
            if (!Directory.Exists(text2))
            {
                Directory.CreateDirectory(text2);
            }
            string path = text2 + "service.log";

            try
            {
                File.AppendAllText(path, "\r\n\r\n", Encoding.ASCII);
            }
            catch (Exception)
            {
            }
            this.LogPath = text2;
            if (Directory.Exists(text2 + "logencode_no"))
            {
                this.isEncode = false;
            }
        }
Exemple #2
0
 public static void BackupLog()
 {
     try
     {
         string text = AppDomain.CurrentDomain.BaseDirectory;
         if (text[text.Length - 1] != Path.DirectorySeparatorChar)
         {
             text += Path.DirectorySeparatorChar;
         }
         string text2 = text + "debuglog" + Path.DirectorySeparatorChar;
         if (text2[text2.Length - 1] != Path.DirectorySeparatorChar)
         {
             text2 += Path.DirectorySeparatorChar;
         }
         if (!Directory.Exists(text2))
         {
             Directory.CreateDirectory(text2);
         }
         string text3 = text2 + "service.log";
         if (File.Exists(text3))
         {
             int num = 1;
             while (num > 0 && num < 4)
             {
                 try
                 {
                     FileInfo fileInfo = new FileInfo(text3);
                     if (fileInfo.Length > 2097152L)
                     {
                         string destFileName = text2 + "service" + DateTime.Now.ToString("yyyyMMddHHmm") + ".log";
                         File.Move(text3, destFileName);
                     }
                     num = 0;
                 }
                 catch (Exception)
                 {
                     num++;
                 }
                 Thread.Sleep(100);
             }
         }
     }
     catch (Exception)
     {
     }
     SyslogMaintain.DeleteLog();
 }