• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# EventLogEntryType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中EventLogEntryType的典型用法代码示例。如果您正苦于以下问题:C# EventLogEntryType类的具体用法?C# EventLogEntryType怎么用?C# EventLogEntryType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EventLogEntryType类属于命名空间,在下文中一共展示了EventLogEntryType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Print

    /// <summary>
    /// Prints a message to the local systems eventlog.
    /// </summary>
    /// <param name="entry"></param>
    /// <param name="type"></param>
    private static void Print(string entry, EventLogEntryType type)
    {
      switch (type)
      {
        case EventLogEntryType.Error: entry = "[error]: " + entry; break;
        case EventLogEntryType.Information: entry = "[comment]: " + entry; break;
        case EventLogEntryType.Warning: entry = "[warning]: " + entry; break;
      }

      try
      {
        if (EventLog.Exists("Application", "."))
        {
          EventLog eventLog = new EventLog("Application", ".", "EasyHook");

#if !DEBUG
                if(InType == EventLogEntryType.Error)
#endif
          eventLog.WriteEntry(entry, type);
        }
      }
      catch
      {
      }

#if DEBUG
      Console.WriteLine(entry);
#endif
    }
开发者ID:rnpowerconsulting,项目名称:appstract,代码行数:34,代码来源:LogService.cs


示例2: AddWindowsEventLog

        private void AddWindowsEventLog(string message, EventLogEntryType logType = EventLogEntryType.Information, string moduleName = "", int codeErreur = 0, bool fromFileLogEvent = false)
        {
            EventLog evLog = new EventLog(Const.WINDOWS_LOG_NAME);

            message = string.Concat(message, "\r\n", "Module : ", moduleName);
            evLog.Source = Const.DEFAULT_APPLICATION_NAME;

            InitWindowsEventLog();

            try
            {
                evLog.WriteEntry(message, logType, codeErreur);
            }
            catch (Exception ex)
            {
                if (!fromFileLogEvent)
                {
                    AddFileEventLog("Impossible d'écrire dans le journal de log " + Log.Const.WINDOWS_LOG_NAME + ".\r\nLe journal doit être créé préalablement avec un compte Administrateur.\r\nMessage :\r\n" + message + "\r\nException : " + ex.Message, logType, moduleName, codeErreur, true);
                }
            }
            finally
            {
                evLog.Close();
            }
        }
开发者ID:ThomasGille,项目名称:Agence-immobili-re,代码行数:25,代码来源:Log.cs


示例3: EventlogListener

        public EventlogListener(string protocol, string source, string category, EventLogEntryType[] types, string key, int value, IMonitoringChannel channel)
        {
            if (protocol == null)
                throw new ArgumentNullException("protocol");

            if (key == null)
                throw new ArgumentNullException("key");

            if (channel == null)
                throw new ArgumentNullException("channel");

            this.key = key;
            this.value = value;

            this.channel = channel;
            this.types = types;

            this.protocol = protocol;
            this.source = source;
            this.category = category;

            try
            {
                this.Initialize();
            }
            catch (ArgumentException exception)
            {
                throw new ArgumentException(
                    exception.Message + " (" + protocol + ")",
                    exception);
            }
        }
开发者ID:Krylon360,项目名称:graphite-client,代码行数:32,代码来源:EventlogListener.cs


示例4: LoggingUtil

 public LoggingUtil(EventLogEntryType min, EventLogEntryType max, String applicationName)
 {
     isSytemEvent = true;
     minSysLevel = min;
     maxSysLevel = max;
     _logFile.Source = applicationName;
 }
开发者ID:PGDJ,项目名称:alt-logger,代码行数:7,代码来源:LoggingUtil.cs


示例5: WriteEntry

 //Write entry log with custome event log entry type
 public void WriteEntry(string message, EventLogEntryType entryType)
 {
     if (enableDebugLog)
     {
         debugLog.WriteEntry(message, entryType);
     }
 }
开发者ID:vuongtran,项目名称:dojo-code,代码行数:8,代码来源:SignalService.cs


示例6: Log

 /// <summary/>
 /// <param name="message"/>
 /// <param name="eventLogType"/>
 /// <exclude/>
 public virtual void Log(string message, EventLogEntryType eventLogType)
 {
     lock (lockObj)
     {
         this.eventLog.WriteEntry(message, eventLogType, this.eventId);
     }
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:11,代码来源:EventLogger.cs


示例7: EventLog

 static void EventLog(String evt, EventLogEntryType tpy)
 {
     if (bEventLog)
         eventLog.WriteEntry(evt, tpy);
     //Console.WriteLine(evt);
     //MessageBox.Show(evt);
 }
开发者ID:CNU-Developers,项目名称:CNUServiceAndUpdator,代码行数:7,代码来源:Updater2.xaml.cs


示例8: WriteEventLogEntry

 public void WriteEventLogEntry(string Message, EventLogEntryType type)
 {
     if(_eventLog!=null)
         _eventLog.WriteEntry(Message, type);
     else
         throw new Exception("Unable to write to event log : not initialized. \r\nMessage to write:\r\n" + Message);
 }
开发者ID:GermanGlushkov,项目名称:FieldInformer,代码行数:7,代码来源:LogWriter.cs


示例9: Log

        public static void Log(string message, EventLogEntryType logType, [CallerMemberName] string memberName = "",
            [CallerLineNumber] int lineNumber = 0) {
            try {
                using (StreamWriter log = new StreamWriter("logs.txt", true)) {
                    string _out =
                        $"[{DateTime.Now.ToString("dd/MM hh:mm")} {Enum.GetName(typeof(EventLogEntryType), logType)}] ";

                    switch (logType) {
                        case EventLogEntryType.SuccessAudit:
                        case EventLogEntryType.FailureAudit:
                        case EventLogEntryType.Warning:
                        case EventLogEntryType.Error:
                            _out += $"from `{memberName}' at {lineNumber}: {message}";

                            Console.WriteLine(_out);
                            log.WriteLine(_out);
                            log.Flush();
                            break;
                        case EventLogEntryType.Information:
                            _out += message;

                            Console.WriteLine(_out);
                            log.WriteLine(_out);
                            log.Flush();
                            break;
                        default:
                            throw new ArgumentOutOfRangeException(nameof(logType), logType, null);
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine($"||| Logging error occured: {ex}", EventLogEntryType.Error);
            }
        }
开发者ID:SemiViral,项目名称:Evealyn-IRC-Bot,代码行数:33,代码来源:Writer.cs


示例10: Write

        private static void Write(string message, EventLogEntryType type)
        {
            if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, "Application");

            EventLog.WriteEntry(sSource, message, type, eventID);
        }
开发者ID:SStewart-Ebsco,项目名称:TFS-Merge,代码行数:7,代码来源:EventLogHelper.cs


示例11: WriteEventLog

 private static void WriteEventLog(string source, string content, EventLogEntryType type)
 {
     try
     {
         if (!EventLog.SourceExists(source))
         {
             EventLog.CreateEventSource(source, "ECCentral.Service");
         }
         using (EventLog errorLog = new EventLog())
         {
             errorLog.Source = source;
             errorLog.WriteEntry(content, type);
         }
     }
     catch (Exception ex)
     {
         try
         {
             using (EventLog log = new EventLog("Application", ".", "ECCentral.Service.Utility"))
             {
                 log.WriteEntry(ex.ToString(), EventLogEntryType.Error);
             }
         }
         catch
         {
         }
     }
 }
开发者ID:ZhouHengYi,项目名称:HFramework,代码行数:28,代码来源:Logger.cs


示例12: BaseWriteEntry

 private void BaseWriteEntry(string message, EventLogEntryType logType, int eventId)
 {
     if (this.HasInitialized)
     {
         this.LoggerProxy.Process(new LogObject(message, logType, eventId));
     }
 }
开发者ID:ashuai,项目名称:SqlMigrator,代码行数:7,代码来源:Logger.cs


示例13: Save

 /// <summary>
 /// Saves the specified _content.
 /// </summary>
 /// <param name="_content">The _content.</param>
 /// <param name="_logType">Type of the _log.</param>
 /// <returns>System.String.</returns>
 public Result Save(string _content, EventLogEntryType _logType)
 {
     content = _content;
     logType = _logType;
     logPath = @"C:\Cube\Logs\";
     return AddToFile();
 }
开发者ID:bkanlica,项目名称:CubeXrmFramework,代码行数:13,代码来源:TextLogger.cs


示例14: Write

        public void Write(string msg, EventLogEntryType type)
        {
            Console.WriteLine(msg);

            // TODO: REBUILD
            //_log.WriteEntry(msg, type);
        }
开发者ID:NunoRodrigues,项目名称:ServicesFrameworkAndGUI,代码行数:7,代码来源:Logger.cs


示例15: Log

    public static void Log(object sender, EventLogEntryType logType, string information) {
      if (sender == null)
        sender = new object();
      if (!Enabled)
        return;
      if (!ShowAll && logType != EventLogEntryType.Error && logType != EventLogEntryType.SuccessAudit)
        return;
      var origin = sender.GetType().FullName;
      var trace = new StringBuilder();

      if (logType == EventLogEntryType.Error) {
        var t = new StackTrace();
        for (var i = 0; i < t.FrameCount; ++i) {
          var declaringType = t.GetFrame(i).GetMethod().DeclaringType;
          if (declaringType != null)
            trace.Append(declaringType.FullName + "." + t.GetFrame(i).GetMethod().Name + "\r\n");
        }
      }
      if (_log != null) {
        try {
          _log.WriteEntry(origin + ": " + information + "\r\n\r\nTRACE:\r\n" + trace, logType);
        } catch {}
      }
      OnEvent?.Invoke(logType, sender, trace.ToString(), information);
    }
开发者ID:Latency,项目名称:TINTIN-.NET,代码行数:25,代码来源:EventLogger.cs


示例16: WriteEntry

        public void WriteEntry(string message, EventLogEntryType type)
        {
            if (!isEnabled) return;
            switch (logType)
            {
                case LogType.EventLog:
                    Log.WriteEntry(message, type); break;
                case LogType.TextLog:
                    string filename = "log_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                    try
                    {
                        if (!Directory.Exists(logPath)) Directory.CreateDirectory(logPath);
                        File.AppendAllText(logPath + filename, DateTime.Now.ToLongTimeString() + " : " + type + " : " + message + Environment.NewLine);
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(new TimeSpan(0, 0, 2));
                        try
                        {
                            if (!Directory.Exists(logPath)) Directory.CreateDirectory(logPath);
                            File.AppendAllText(logPath + filename, DateTime.Now.ToLongTimeString() + " : " + type + " : " + message + Environment.NewLine);
                        }
                        catch (Exception)
                        {

                        }
                    }
                    break;
                default: break;
            }
        }
开发者ID:giangcoffee,项目名称:cafef.redis,代码行数:31,代码来源:LogUtils.cs


示例17: WriteErrorLog

 // 把错误信息写到日志文件里
 public void WriteErrorLog(string strText,
     EventLogEntryType type = EventLogEntryType.Error)
 {
     EventLog Log = new EventLog();
     Log.Source = "dp2ZServer";
     Log.WriteEntry(strText, EventLogEntryType.Error);
 }
开发者ID:renyh1013,项目名称:dp2,代码行数:8,代码来源:UcApplication.cs


示例18: Save

 /// <summary>
 /// Saves the specified _content.
 /// </summary>
 /// <param name="_content">The _content.</param>
 /// <param name="_logType">Type of the _log.</param>
 /// <param name="param">The parameter.</param>
 /// <returns>Result.</returns>
 public Result Save(string _content, EventLogEntryType _logType, object param)
 {
     content = _content;
     logType = _logType;
     sqlConnection = (SqlConnection)param;
     return AddToSQLTable();
 }
开发者ID:bkanlica,项目名称:CubeXrmFramework,代码行数:14,代码来源:SqlLogger.cs


示例19: EventLogWriteEntry

 public void EventLogWriteEntry(string message, EventLogEntryType type)
 {
     if (HostedApplication.EventLogEnabled)
     {
         EventLog.WriteEntry(message, type);
     }
 }
开发者ID:dblock,项目名称:dblog,代码行数:7,代码来源:WebService.cs


示例20: WriteToEventLog

 public static void WriteToEventLog(string sourceName, string logName, EventLogEntryType error, int eventID, string message)
 {
     try
     {
         SiAuto.Main.EnterMethod("Helper.WriteToEventLog");
         /*--------- Your code goes here-------*/
         using (EventLog elog = new EventLog())
         {
             if (!EventLog.SourceExists(sourceName))
             {
                 EventLog.CreateEventSource(sourceName, logName);
             }
             elog.Source = sourceName;
             elog.EnableRaisingEvents = true;
             elog.WriteEntry(message, error, eventID);
         }
         /*------------------------------------*/
     }
     catch (Exception ex)
     {
         SiAuto.Main.LogException(ex);
         //throw ex;
     }
     finally
     {
         SiAuto.Main.LeaveMethod("Helper.WriteToEventLog");
     }
 }
开发者ID:gvallejo,项目名称:reajetservice,代码行数:28,代码来源:Helper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# EventLogProvider类代码示例发布时间:2022-05-24
下一篇:
C# EventListener类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap