コード例 #1
0
        public static void LogError(Exception ex)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                Exception     e  = ex;

                sb.AppendLine("----" + DateTime.Now + " ----");
                while (e != null)
                {
                    sb.AppendLine(getErrorText(e));
                    e = e.InnerException;
                }

                sb.AppendLine(new string('-', 25));

                Server.s.ErrorCase(sb.ToString());
                lock (_lockObject)
                {
                    _errorCache.Enqueue(sb.ToString());
                    Monitor.Pulse(_lockObject);
                }



                if (NeedRestart == true)
                {
                    Server.listen.Close();
                    Server.Setup();

                    NeedRestart = false;
                }
            } catch (Exception e) {
                File.AppendAllText("ErrorLogError.log", getErrorText(e));
                Server.s.Log("There was an error in the error logger!");
            }
        }