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


C# EventLogEntryType类代码示例

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


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


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