当前位置: 首页>>代码示例>>C#>>正文


C# EventLog.Close方法代码示例

本文整理汇总了C#中System.Diagnostics.EventLog.Close方法的典型用法代码示例。如果您正苦于以下问题:C# EventLog.Close方法的具体用法?C# EventLog.Close怎么用?C# EventLog.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.EventLog的用法示例。


在下文中一共展示了EventLog.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DebugWriteLine

        private void DebugWriteLine(EventLogEntryType type, string message)
        {
            _log = new EventLog();
            _log.Source = "ApplicationLog";
            
            _log.WriteEntry(message, type);

            _log.Close();
        }
开发者ID:KalyanArangam,项目名称:SSWTV.DevSuperPower.DI,代码行数:9,代码来源:EventLogLogger.cs

示例2: CloseEventLog

 private static void CloseEventLog(EventLog log)
 {
     try
     {
         log.Close();
     }
     catch (Win32Exception we)
     {
         Console.WriteLine("Error closing event log: " + we.ToString());
     }
 }
开发者ID:oblivious,项目名称:Oblivious,代码行数:11,代码来源:EventLogClassTest.cs

示例3: SqlExceptionHandling

        public static void SqlExceptionHandling(SqlException sqlex, string strModule, string strMethod, string strMsg)
        {
            EventLog objEventLog = new EventLog();

            string strApplicationName = "SLDDBLog";
            objEventLog.Source = strApplicationName;

            objEventLog.Log = strApplicationName;
            objEventLog.WriteEntry(Environment.NewLine + "Date : " + DateTime.Now + Environment.NewLine + "Module Name : " + strModule + Environment.NewLine + "Method Name : " + strMethod + Environment.NewLine + "Exception Number : " + sqlex.ErrorCode + Environment.NewLine + "Exception Message : " + sqlex.Message + Environment.NewLine + "Additional Information : " + strMsg, EventLogEntryType.Error);
            objEventLog.Close();
            objEventLog.Dispose();
        }
开发者ID:pratikmoda,项目名称:SLD,代码行数:12,代码来源:ErrorHandling.cs

示例4: Log

 public static void Log(Exception ex)
 {
     var log = new EventLog
     {
         Source = "Xuat_Nhap_Excel/BizService"
     };
     log.WriteEntry(string.Concat(new object[] { ex.Message, Environment.NewLine,
                                                 ex.Source, Environment.NewLine,
                                                 ex.StackTrace,
                                                 ex.TargetSite,
                                                 ex.InnerException }), EventLogEntryType.Error, 100);
     log.Close();
 }
开发者ID:tungph80,项目名称:TTMWeb,代码行数:13,代码来源:log2File.cs

示例5: Log

 private void Log(string message, int eventId, EventLogEntryType type)
 {
     try
     {
         InitSource();
         EventLog ev = new EventLog(LogName, Environment.MachineName, Source);
         ev.WriteEntry(message, type, eventId);
         ev.Close();
     }
     catch
     {
     }
 }
开发者ID:kaloutsa,项目名称:maksudproject,代码行数:13,代码来源:EventLogger.cs

示例6: OnLog

        /// <summary>
        /// Called when [log].
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="message">The message.</param>
        public static void OnLog(EventLogEntryType type, string message)
        {
            LogHandler handler = Log;
            if (handler != null) handler(type, "(T"+ Thread.CurrentThread.ManagedThreadId +") " + message);
            if (type == EventLogEntryType.Information) return;

            try
            {
                var log = new EventLog { Log = "Application", Source = "TS3-Bot" };
                log.WriteEntry(message, type);
                log.Close();
            }
            catch
            { }
        }
开发者ID:Oslo-Lions-Elektroniske-Sportsklubb,项目名称:TS3-Bot,代码行数:20,代码来源:LogService.cs

示例7: WriteEventLog

 private static void WriteEventLog(string event_source, string content, EventLogEntryType type)
 {
     try
     {
         if (!EventLog.SourceExists(event_source))
         {
             EventLog.CreateEventSource(event_source, event_source);
         }
         using (EventLog elog = new EventLog())
         {
             elog.Log = event_source;
             elog.Source = event_source;
             elog.WriteEntry(content, type);
             elog.Close();
         }
     }
     catch { }
 }
开发者ID:jeanmahai,项目名称:PublicTools,代码行数:18,代码来源:EventLogEmitter.cs

示例8: ErrorLog

 public static void ErrorLog(string LogStr, EventLogEntryType Type)
 {
     try
     {
         System.Security.Principal.WindowsImpersonationContext wic = WindowsIdentity.Impersonate(IntPtr.Zero);
         var El = new EventLog();
         if (EventLog.SourceExists(ErrorLogname) == false)
             EventLog.CreateEventSource(ErrorLogname, ErrorLogname);
         El.Source = ErrorLogname;
         El.WriteEntry(LogStr, Type);
         El.Close();
         wic.Undo();
     }
     catch (Exception Ex87)
     {
         WriteTextLog(Ex87.Message + "\r" + LogStr);
     }
 }
开发者ID:Santhoshonet,项目名称:ITXWorkflowAutomaticDeployment,代码行数:18,代码来源:MyUtilities.cs

示例9: ErrorLog

 public static void ErrorLog(string LogStr, EventLogEntryType Type)
 {
     try
     {
         WindowsImpersonationContext wic = WindowsIdentity.Impersonate(IntPtr.Zero);
         var El = new EventLog();
         if (EventLog.SourceExists("CIMBTimeSheet") == false)
             EventLog.CreateEventSource("CIMBTimeSheet", "CIMBTimeSheet");
         El.Source = "CIMBTimeSheet";
         El.WriteEntry(LogStr, Type);
         El.Close();
         wic.Undo();
     }
     catch (Exception Ex87)
     {
         WriteTextLog(Ex87.Message + "\r" + LogStr);
     }
 }
开发者ID:Vengadeswaran,项目名称:TimeSheet-Project,代码行数:18,代码来源:MyConfiguration.cs

示例10: WriteEventLog

 internal static void WriteEventLog(string content, EventLogEntryType type)
 {
     const string event_source = "Soho.Utility.Logger";
     const string event_name = "Soho.Utility.Logger_Exception";
     try
     {
         if (!EventLog.SourceExists(event_source))
         {
             EventLog.CreateEventSource(event_source, event_name);
         }
         using (EventLog elog = new EventLog())
         {
             elog.Log = event_name;
             elog.Source = event_source;
             elog.WriteEntry(content, type);
             elog.Close();
         }
     }
     catch { }
 }
开发者ID:jeanmahai,项目名称:PublicTools,代码行数:20,代码来源:Logger.cs

示例11: WriteEventLog

        public static void WriteEventLog(Exception exc, string message = "", string eventLogName = Constants.EventLogName)
        {

            try
            {
                if (EventLog.SourceExists(Constants.EventLogName) == true)
                {
                    EventLog myLog = new EventLog();
                    myLog.Source = Constants.EventLogName;
                    myLog.WriteEntry(string.Format("Dev Message {0} ErrorMessage: {1}  \n\nStackTrace: {2}", message, exc.Message, exc.StackTrace), EventLogEntryType.Error);
                    myLog.Close();
                }


            }
            catch (Exception ex)
            {
            }

        }
开发者ID:emospy,项目名称:AmbulanceGraphics,代码行数:20,代码来源:ZoraEventLog.cs

示例12: Log

        public static void Log(string message, EventLogEntryType eventType, EventID eventID)
        {
            const string applicationName = "CIWaterNetService";
            // Create an instance of EventLog
            EventLog eventLog = new EventLog();

            // Check if the event source exists. If not create it.
            if (!System.Diagnostics.EventLog.SourceExists(applicationName))
            {
                EventLog.CreateEventSource(applicationName, "Application");
            }

            // Set the source name for writing log entries.
            eventLog.Source = applicationName;

            // Write an entry to the event log.
            eventLog.WriteEntry(message, eventType,  (int)eventID);

            // Close the Event Log
            eventLog.Close();
        }
开发者ID:CI-Water-DASYCIM,项目名称:USU_ASPNet_AppServer,代码行数:21,代码来源:EventLogger.cs

示例13: ReadEventLog

        public string ReadEventLog(EventLog eventLog, int logcount = 1000)
        {
            var count = logcount;
            var total = eventLog.Entries.Count - 1;
            var sb = new StringBuilder();

            while (count-- > 0)
            {
                var entry = eventLog.Entries[total--];
                sb.AppendFormat("消息:{0};时间:{1};来源:{2};类型:{3};"
                     , entry.Message
                     , entry.TimeGenerated.ToString("yyyy-MM-dd HH:mm:ss.fff")
                     , entry.Source
                     , entry.EntryType.ToString()
                     );
                sb.AppendLine();

            }
            eventLog.Close();

            return sb.ToString();
        }
开发者ID:CrazyBBer,项目名称:CS-WPF-Demo,代码行数:22,代码来源:SystemEventLogMgr.cs

示例14: WriteEvent

 public void WriteEvent(string strMessage, EventLogEntryType type)
 {
     if (!EventLog.SourceExists(this._sourece))
     EventLog.CreateEventSource(this._sourece, this._eventName);
       EventLog eventLog = new EventLog();
       eventLog.Log = this._eventName;
       eventLog.Source = this._sourece;
       try
       {
     eventLog.WriteEntry(strMessage, type);
       }
       catch (Exception ex)
       {
     eventLog.Clear();
     this.WriteEvent("日志文件已满,执行清除操作!", EventLogEntryType.Warning);
     eventLog.WriteEntry(strMessage, type);
       }
       finally
       {
     eventLog.Close();
     eventLog.Dispose();
       }
 }
开发者ID:wangyuanxun,项目名称:DataOperator,代码行数:23,代码来源:WriteLog.cs

示例15: viewLog

        public string viewLog(string log,int maxNum)
        {
            String retVal = "";
            //if(EventLog.SourceExists(log))
            try
            {
                EventLog aLog = new EventLog();
                aLog.Log = log;
                aLog.MachineName = ".";
                //foreach (EventLogEntry entry in aLog.Entries)
                EventLogEntry entry;
                for(int i=aLog.Entries.Count-1;(i>0 && (i > aLog.Entries.Count-1 - maxNum));i--)
                {
                    entry = aLog.Entries[i];
                    retVal += " " + entry.TimeGenerated.ToString().Replace(":","#C#") + ": " + entry.EntryType + " - " + entry.Source + "\n" + entry.Message+"\n";
                }
                aLog.Close();
            }
            catch (Exception e){

            }
            return retVal;
        }
开发者ID:reticon,项目名称:CCMClient,代码行数:23,代码来源:eventLog.cs


注:本文中的System.Diagnostics.EventLog.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。