Beispiel #1
0
        }// end method static void log(string fileName, string msg)

        /// <summary>
        /// Logs an info message to the log
        /// </summary>
        /// <param name="msg">Message to log</param>
        public static void LogInfo(string msg)
        {
            msg = string.Format("Time Stamp: {0}{2}Info: {1}{2}{2}"
                                , DateTime.Now.ToString("hh:mm:ss"), msg, Environment.NewLine);

            FilesUtils.CreateFile(fileName, msg);
        } // end method static void log(string fileName, string msg)
Beispiel #2
0
        }     // end property static string fileName

        /// <summary>
        /// Method Logs an error's message and the stacktrace to the log
        /// </summary>
        /// <param name="ex">Exception to log</param>
        public static void LogError(Exception ex)
        {
            string error       = ex.Message,
                   stackStrace = ex.StackTrace.Trim();

            var msg = string.Format("Time Stamp: {0}{1}", DateTime.Now.ToString("hh:mm:ss"), Environment.NewLine);

            msg += string.Format("Error: {0}{1}", error, Environment.NewLine);

            if (ex.InnerException != null)
            {
                msg += string.Format("Inner Error: {0}{1}", ex.InnerException, Environment.NewLine);
            }

            msg += string.Format("Stacktrace: {0}{1}", stackStrace, Environment.NewLine);

            FilesUtils.CreateFile(fileName, msg);
        }// end method static void LogError(Exception ex)