首页 > 代码库 > 工作执行日志编写

工作执行日志编写

技术分享
 1  /// <summary> 2         /// 路径 3         /// </summary> 4         static string log = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, string.Format("DMS_{0}.log", DateTime.Today.ToString("yyyy-MM-dd"))); 5         //异常记录 6         #region 7         public static void writeLog(string logstr) 8         { 9             File.AppendAllText(log,string.Format("{0}----{1}"+Environment.NewLine,DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),logstr));10         }11         #endregion12     }
执行日志
 /// <summary>        /// 开始执行        /// </summary>        public void StartService()        {            try            {                int runTime = Convert.ToInt32(ConfigurationManager.AppSettings["frequency"].ToString());                timer = new System.Timers.Timer(runTime * 1000);                timer.Elapsed += timer_Elapsed;                timer.Start();            }            catch (Exception ex)            {                Log.WriteLog(ex.Message);            }        }        /// <summary>        /// 每天执行服务相关业务操作        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        void timer_Elapsed(object sender, ElapsedEventArgs e)        {            try            {                Log.WriteLog("开始执行!!!!!!!!");                // 验证开始                CheckImportElectronic();            }            catch (Exception ex)            {                Log.WriteLog(ex.Message);            }        }

 

工作执行日志编写