1 /// <summary>2 ///Path3 /// </summary>4 Static stringLog = Path.Combine (AppDomain.CurrentDomain.SetupInformation.ApplicationBase,string. Format ("Dms_{0}.log", DateTime.Today.ToString ("YYYY-MM-DD")));5 //Exception Record6 #region7 Public Static voidWritelog (stringlogstr)8 {9File.appendalltext (log,string. Format ("{0}----{1}"+environment.newline,datetime.now.tostring ("YYYY-MM-DD HH:mm:ss") , Logstr));Ten } One #endregion A} execution log
<summary>///Start execution///</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>//daily service-related business operations///</summary>//<param name= "Sende R "></param>//<param name=" E "></param> void timer_elapsed (object sender, Elapsedevent Args e) {try {log.writelog ("Start execution!!!!!!!! "); Validation begins checkimportelectronic (); } catch (Exception ex) {Log.writelog (ex. Message); } }
Work Execution Log Writing