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

C# Diagnostics.EventInstance类代码示例

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

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



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

示例1: Main

        static void Main(string[] args)
        {
            //
            // New-EventLog -source "MySource" -logname "MyLog" (cf. https://technet.microsoft.com/en-us/library/hh849768.aspx)
            // Run eventvwr
            // Remove-EventLog -logname "MyLog" (cf. https://technet.microsoft.com/en-us/library/hh849786.aspx)
            //


            WriteLine("Option A");
            var eventLog = new EventLog() {Source = "Application"};
            eventLog.WriteEntry("Message Option A");

            WriteLine("Option B");
            var eventLogB = new EventLog() {Source = "MyLog", EnableRaisingEvents = true};
            var eventInstanceB = new EventInstance(0, 1);
            eventLogB.WriteEvent(eventInstanceB, "Message Option B");

            WriteLine("Option C");
            var eventLogC = new EventLog() {Source = "MyLog"};
            eventLogC.WriteEntry("Message Option C", EventLogEntryType.Error);

            WriteLine("Option D");
            var eventLogD = new EventLog() {Source = "MySource", EnableRaisingEvents = true};
            eventLogD.WriteEntry("Message Option D", EventLogEntryType.Error);

            WriteLine("Done.");
            ReadLine();
        }
开发者ID:dennido5,项目名称:70-483,代码行数:29,代码来源:Program.cs


示例2: OnEventWritten

        protected override void OnEventWritten(EventWrittenEventArgs eventData)
        {
            var test = new EventInstance(eventData.EventId, (int)eventData.Task, EventLogEntryType.Warning);
            _eventLog.WriteEvent(test, new string[] { "OpCode=1" });

            _eventLog.WriteEntry("Event Occurring", EventLogEntryType.Information, eventData.EventId, (short)eventData.Task);
        }
开发者ID:calvinnorton,项目名称:SampleLogApplication,代码行数:7,代码来源:EventLogListener.cs


示例3: Constructor1

		public void Constructor1 ()
		{
			EventInstance ei = null;

			ei = new EventInstance (5, 10);
			Assert.AreEqual (10, ei.CategoryId, "#A1");
			Assert.AreEqual (5, ei.InstanceId, "#A2");
			Assert.AreEqual (EventLogEntryType.Information, ei.EntryType, "#A3");

			ei = new EventInstance (0, 0);
			Assert.AreEqual (0, ei.CategoryId, "#B1");
			Assert.AreEqual (0, ei.InstanceId, "#B2");
			Assert.AreEqual (EventLogEntryType.Information, ei.EntryType, "#B3");

			ei = new EventInstance (uint.MaxValue, ushort.MaxValue);
			Assert.AreEqual (ushort.MaxValue, ei.CategoryId, "#C1");
			Assert.AreEqual (uint.MaxValue, ei.InstanceId, "#C2");
			Assert.AreEqual (EventLogEntryType.Information, ei.EntryType, "#C3");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:19,代码来源:EventInstanceTest.cs


示例4: LogProviderLifecycleEvent

 internal override void LogProviderLifecycleEvent(LogContext logContext, string providerName, ProviderState newState)
 {
     int providerLifecycleEventId = GetProviderLifecycleEventId(newState);
     if (providerLifecycleEventId != -1)
     {
         Hashtable mapArgs = new Hashtable();
         mapArgs["ProviderName"] = providerName;
         mapArgs["NewProviderState"] = newState.ToString();
         FillEventArgs(mapArgs, logContext);
         EventInstance entry = new EventInstance((long) providerLifecycleEventId, 6) {
             EntryType = EventLogEntryType.Information
         };
         string eventDetail = this.GetEventDetail("ProviderLifecycleContext", mapArgs);
         this.LogEvent(entry, new object[] { providerName, newState, eventDetail });
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:EventLogLogProvider.cs


示例5: LogPipelineExecutionDetailEvent

 private void LogPipelineExecutionDetailEvent(LogContext logContext, string pipelineExecutionDetail, int detailSequence, int detailTotal)
 {
     int num = 800;
     Hashtable mapArgs = new Hashtable();
     mapArgs["PipelineExecutionDetail"] = pipelineExecutionDetail;
     mapArgs["DetailSequence"] = detailSequence;
     mapArgs["DetailTotal"] = detailTotal;
     FillEventArgs(mapArgs, logContext);
     EventInstance entry = new EventInstance((long) num, 8) {
         EntryType = EventLogEntryType.Information
     };
     string eventDetail = this.GetEventDetail("PipelineExecutionDetailContext", mapArgs);
     this.LogEvent(entry, new object[] { logContext.CommandLine, eventDetail, pipelineExecutionDetail });
 }
开发者ID:nickchal,项目名称:pash,代码行数:14,代码来源:EventLogLogProvider.cs


示例6: LogEngineLifecycleEvent

 internal override void LogEngineLifecycleEvent(LogContext logContext, EngineState newState, EngineState previousState)
 {
     int engineLifecycleEventId = GetEngineLifecycleEventId(newState);
     if (engineLifecycleEventId != -1)
     {
         Hashtable mapArgs = new Hashtable();
         mapArgs["NewEngineState"] = newState.ToString();
         mapArgs["PreviousEngineState"] = previousState.ToString();
         FillEventArgs(mapArgs, logContext);
         EventInstance entry = new EventInstance((long) engineLifecycleEventId, 4) {
             EntryType = EventLogEntryType.Information
         };
         string eventDetail = this.GetEventDetail("EngineLifecycleContext", mapArgs);
         this.LogEvent(entry, new object[] { newState, previousState, eventDetail });
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:EventLogLogProvider.cs


示例7: LogCommandLifecycleEvent

 internal override void LogCommandLifecycleEvent(Func<LogContext> getLogContext, CommandState newState)
 {
     LogContext logContext = getLogContext();
     int commandLifecycleEventId = GetCommandLifecycleEventId(newState);
     if (commandLifecycleEventId != -1)
     {
         Hashtable mapArgs = new Hashtable();
         mapArgs["NewCommandState"] = newState.ToString();
         FillEventArgs(mapArgs, logContext);
         EventInstance entry = new EventInstance((long) commandLifecycleEventId, 5) {
             EntryType = EventLogEntryType.Information
         };
         string eventDetail = this.GetEventDetail("CommandLifecycleContext", mapArgs);
         this.LogEvent(entry, new object[] { logContext.CommandName, newState, eventDetail });
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:EventLogLogProvider.cs


示例8: WriteEvent4_Values_Null

		public void WriteEvent4_Values_Null ()
		{
			if (EventLog.SourceExists ("monotempsource", "."))
				Assert.Ignore ("Event log source 'monotempsource' should not exist.");

			if (EventLog.Exists ("monologtemp", "."))
				Assert.Ignore ("Event log 'monologtemp' should not exist.");

			EventLog.CreateEventSource ("monotempsource", "monologtemp");
			try {
				byte [] data = new byte [] { 23, 54 };
				EventInstance instance = new EventInstance (5, 666,
					EventLogEntryType.Warning);
				EventLog.WriteEvent ("monotempsource", instance, data, (object) null);

				using (EventLog eventLog = new EventLog ("monologtemp", ".", "monotempsource")) {
					// MSBUG: Assert.AreEqual (1, eventLog.Entries.Count, "#A1");
					Assert.AreEqual ("monologtemp", eventLog.Log, "#A2");
					Assert.AreEqual ("monotempsource", eventLog.Source, "#A3");
					Assert.IsTrue (EventLog.Exists ("monologtemp"), "#A4");
					Assert.IsTrue (EventLog.SourceExists ("monotempsource"), "#A5");
					Assert.IsTrue (EventLog.SourceExists ("monologtemp"), "#A6");
					Assert.AreEqual ("monologtemp", EventLog.LogNameFromSourceName ("monotempsource", "."), "#A7");

					EventLogEntry entry = eventLog.Entries [eventLog.Entries.Count - 1];
					Assert.IsNotNull (entry, "#B1");
					Assert.IsNotNull (entry.Category, "#B2");
					Assert.AreEqual ("(666)", entry.Category, "#B3");
					Assert.AreEqual (666, entry.CategoryNumber, "#B4");
					Assert.IsNotNull (entry.Data, "#B5");
					Assert.AreEqual (data, entry.Data, "#B6");
					Assert.AreEqual (EventLogEntryType.Warning, entry.EntryType, "#B7");
					Assert.AreEqual (5, entry.EventID, "#B8");
					Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
					Assert.IsNotNull (entry.MachineName, "#B10");
					Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
					Assert.IsNotNull (entry.ReplacementStrings, "#B12");
					Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
					Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
					Assert.IsNotNull (entry.Source, "#B15");
					Assert.AreEqual ("monotempsource", entry.Source, "#B16");
					Assert.IsNull (entry.UserName, "#B17");
				}
			} finally {
				if (EventLog.Exists ("monologtemp"))
					EventLog.Delete ("monologtemp");
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:48,代码来源:EventLogTest.cs


示例9: WriteEvent4_Source_Empty

		[ExpectedException (typeof (ArgumentException))] // Source property was not set before writing to the event log
		public void WriteEvent4_Source_Empty ()
		{
			EventInstance instance = new EventInstance (5, 1,
				EventLogEntryType.Information);
			EventLog.WriteEvent (string.Empty, instance, new byte [0]);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:EventLogTest.cs


示例10: CreateEventInstance

 private EventInstance CreateEventInstance(TraceEventType severity, int id)
 {
     if (id > 0xffff)
     {
         id = 0xffff;
     }
     if (id < 0)
     {
         id = 0;
     }
     EventInstance instance1 = new EventInstance((long)id, 0);
     if ((severity == TraceEventType.Error) || (severity == TraceEventType.Critical))
     {
         instance1.EntryType = EventLogEntryType.Error;
         return instance1;
     }
     if (severity == TraceEventType.Warning)
     {
         instance1.EntryType = EventLogEntryType.Warning;
         return instance1;
     }
     instance1.EntryType = EventLogEntryType.Information;
     return instance1;
 }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:24,代码来源:EventLogTraceListener.cs


示例11: WriteEvent

		public static void WriteEvent (string source, EventInstance instance, byte [] data, params object [] values)
		{
			using (EventLog eventLog = new EventLog ()) {
				eventLog.Source = source;
				eventLog.WriteEvent (instance, data, values);
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:7,代码来源:EventLog.cs


示例12: TestCustomEventWriter

 /// <summary>
 /// The signature of this method does not change, it provides everything you need to know about the
 /// log event, you may prepend fixed arguments to the arguments parameters, then simply call write.
 /// BTW, since this is called from the formatter method, or from the exception constructor, you may
 /// assume the current stack is the execution context for the exception.  The exception's StackTrace
 /// will be empty since the exception has not been thrown.
 /// </summary>
 public static void TestCustomEventWriter(string eventLog, string eventSource, int category, EventLogEntryType eventType, long eventId, object[] arguments, Exception error)
 {
     _lastLog = new EventLog(eventLog, ".", eventSource);
     _lastEvent = new EventInstance(eventId, category, eventType);
     _lastArgs = (string[])arguments;
 }
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:13,代码来源:TestResXAutoLog.cs


示例13: WriteEvent2_Source_DoesNotExist

		public void WriteEvent2_Source_DoesNotExist ()
		{
			if (EventLogImplType == NULL_IMPL)
				// test cannot pass with NULL implementation
				return;

			if (EventLog.SourceExists ("monotempsource", "."))
				Assert.Ignore ("Event log source 'monotempsource' should not exist.");

			if (EventLog.SourceExists ("monoothersource", "."))
				Assert.Ignore ("Event log source 'monoothersource' should not exist.");

			if (EventLog.Exists ("monologtemp", "."))
				Assert.Ignore ("Event log 'monologtemp' should not exist.");

			EventLog.CreateEventSource ("monoothersource", "monologtemp");
			try {
				using (EventLog eventLog = new EventLog ("monologtemp", ".", "monotempsource")) {
					byte [] data = new byte [] { 23, 54 };
					EventInstance instance = new EventInstance (5, 1,
						EventLogEntryType.Error);
					eventLog.WriteEvent (instance, data, "replace1", "replace2");

					// MSBUG: Assert.AreEqual (1, eventLog.Entries.Count, "#A1");
					Assert.AreEqual ("monologtemp", eventLog.Log, "#A2");
					Assert.AreEqual ("monotempsource", eventLog.Source, "#A3");
					Assert.IsTrue (EventLog.Exists ("monologtemp"), "#A4");
					Assert.IsTrue (EventLog.SourceExists ("monotempsource"), "#A5");
					Assert.IsTrue (EventLog.SourceExists ("monologtemp"), "#A6");
					Assert.AreEqual ("monologtemp", EventLog.LogNameFromSourceName ("monotempsource", "."), "#A7");

					EventLogEntry entry = eventLog.Entries [eventLog.Entries.Count - 1];
					Assert.IsNotNull (entry, "#B1");
					Assert.IsNotNull (entry.Category, "#B2");
					Assert.AreEqual ("(1)", entry.Category, "#B3");
					Assert.AreEqual (1, entry.CategoryNumber, "#B4");
					Assert.IsNotNull (entry.Data, "#B5");
					Assert.AreEqual (data, entry.Data, "#B6");
					Assert.AreEqual (EventLogEntryType.Error, entry.EntryType, "#B7");
					Assert.AreEqual (5, entry.EventID, "#B8");
					Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
					Assert.IsNotNull (entry.MachineName, "#B10");
					Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
					Assert.IsNotNull (entry.ReplacementStrings, "#B12");
					Assert.AreEqual (2, entry.ReplacementStrings.Length, "#B13");
					Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
					Assert.AreEqual ("replace2", entry.ReplacementStrings [1], "#B15");
					Assert.IsNotNull (entry.Source, "#B16");
					Assert.AreEqual ("monotempsource", entry.Source, "#B17");
					Assert.IsNull (entry.UserName, "#B18");
				}
			} finally {
				if (EventLog.Exists ("monologtemp"))
					EventLog.Delete ("monologtemp");
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:56,代码来源:EventLogTest.cs


示例14: WriteEvent4

		public void WriteEvent4 ()
		{
			if (EventLog.SourceExists ("monotempsource", "."))
				Assert.Ignore ("Event log source 'monotempsource' should not exist.");

			if (EventLog.Exists ("monologtemp", "."))
				Assert.Ignore ("Event log 'monologtemp' should not exist.");

			EventLog.CreateEventSource ("monotempsource", "monologtemp");
			try {
				byte [] data = new byte [] { 23, 54 };
				EventInstance instance = new EventInstance (5, 666,
					EventLogEntryType.FailureAudit);
				EventLog.WriteEvent ("monotempsource", instance, data, 5, "new"
					+ Environment.NewLine + "line", true, null);

				using (EventLog eventLog = new EventLog ("monologtemp", ".", "monotempsource")) {
					// MSBUG: Assert.AreEqual (1, eventLog.Entries.Count, "#A1");
					Assert.AreEqual ("monologtemp", eventLog.Log, "#A2");
					Assert.AreEqual ("monotempsource", eventLog.Source, "#A3");
					Assert.IsTrue (EventLog.Exists ("monologtemp"), "#A4");
					Assert.IsTrue (EventLog.SourceExists ("monotempsource"), "#A5");
					Assert.IsTrue (EventLog.SourceExists ("monologtemp"), "#A6");
					Assert.AreEqual ("monologtemp", EventLog.LogNameFromSourceName ("monotempsource", "."), "#A7");

					EventLogEntry entry = eventLog.Entries [eventLog.Entries.Count - 1];
					Assert.IsNotNull (entry, "#B1");
					Assert.IsNotNull (entry.Category, "#B2");
					Assert.AreEqual ("(666)", entry.Category, "#B3");
					Assert.AreEqual (666, entry.CategoryNumber, "#B4");
					Assert.IsNotNull (entry.Data, "#B5");
					Assert.AreEqual (data, entry.Data, "#B6");
					Assert.AreEqual (EventLogEntryType.FailureAudit, entry.EntryType, "#B7");
					Assert.AreEqual (5, entry.EventID, "#B8");
					Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
					Assert.IsNotNull (entry.MachineName, "#B10");
					Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
					Assert.IsNotNull (entry.ReplacementStrings, "#B12");
					Assert.AreEqual (4, entry.ReplacementStrings.Length, "#B13");
					Assert.AreEqual ("5", entry.ReplacementStrings [0], "#B14");
					Assert.AreEqual ("new" + Environment.NewLine + "line", entry.ReplacementStrings [1], "#B15");
					Assert.AreEqual (true.ToString (), entry.ReplacementStrings [2], "#B16");
					Assert.AreEqual (string.Empty, entry.ReplacementStrings [3], "#B17");
					Assert.IsNotNull (entry.Source, "#B18");
					Assert.AreEqual ("monotempsource", entry.Source, "#B19");
					Assert.IsNull (entry.UserName, "#B20");

					EventLog.WriteEvent ("monotempsource", instance, data);

					entry = eventLog.Entries [eventLog.Entries.Count - 1];
					Assert.IsNotNull (entry, "#C1");
					Assert.IsNotNull (entry.Category, "#C2");
					Assert.AreEqual ("(666)", entry.Category, "#C3");
					Assert.AreEqual (666, entry.CategoryNumber, "#C4");
					Assert.IsNotNull (entry.Data, "#C5");
					Assert.AreEqual (data, entry.Data, "#C6");
					Assert.AreEqual (EventLogEntryType.FailureAudit, entry.EntryType, "#C7");
					Assert.AreEqual (5, entry.EventID, "#C8");
					Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
					Assert.IsNotNull (entry.MachineName, "#C10");
					Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
					Assert.IsNotNull (entry.ReplacementStrings, "#C12");
					Assert.AreEqual (0, entry.ReplacementStrings.Length, "#C13");
					Assert.IsNotNull (entry.Source, "#C14");
					Assert.AreEqual ("monotempsource", entry.Source, "#C15");
					Assert.IsNull (entry.UserName, "#C16");
				}
			} finally {
				if (EventLog.Exists ("monologtemp"))
					EventLog.Delete ("monologtemp");
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:72,代码来源:EventLogTest.cs


示例15: WriteEvent

 public void WriteEvent(EventInstance instance, params Object[] values) {
     WriteEvent(instance, null, values);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:3,代码来源:EventLogInternal.cs


示例16: WriteEvent4_Source_DoesNotExist

		public void WriteEvent4_Source_DoesNotExist ()
		{
			if (EventLogImplType == NULL_IMPL)
				// test cannot pass with NULL implementation
				return;

			if (EventLog.SourceExists ("monotempsource", "."))
				Assert.Ignore ("Event log source 'monotempsource' should not exist.");

			bool applicationLogExists = EventLog.Exists ("Application");
			try {
				byte [] data = new byte [] { 23, 54 };
				EventInstance instance = new EventInstance (666, 1,
					EventLogEntryType.Error);
				EventLog.WriteEvent ("monotempsource", instance, data, "replace1", "replace2");

				Assert.IsTrue (EventLog.Exists ("Application"), "#A1");
				Assert.IsTrue (EventLog.SourceExists ("monotempsource"), "#A2");
				Assert.AreEqual ("Application", EventLog.LogNameFromSourceName ("monotempsource", "."), "#A3");

				if (EventLogImplType == WIN32_IMPL)
					// win32 API does not return entries in order for
					// Application log
					return;

				using (EventLog eventLog = new EventLog ("Application", ".", "monotempsource")) {
					EventLogEntry entry = eventLog.Entries [eventLog.Entries.Count - 1];
					Assert.IsNotNull (entry, "#B1");
					Assert.IsNotNull (entry.Category, "#B2");
					Assert.AreEqual ("(1)", entry.Category, "#B3");
					Assert.AreEqual (1, entry.CategoryNumber, "#B4");
					Assert.IsNotNull (entry.Data, "#B5");
					Assert.AreEqual (data, entry.Data, "#B6");
					Assert.AreEqual (EventLogEntryType.Error, entry.EntryType, "#B7");
					Assert.AreEqual (666, entry.EventID, "#B8");
					Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
					Assert.IsNotNull (entry.MachineName, "#B10");
					Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
					Assert.IsNotNull (entry.ReplacementStrings, "#B12");
					Assert.AreEqual (2, entry.ReplacementStrings.Length, "#B13");
					Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
					Assert.AreEqual ("replace2", entry.ReplacementStrings [1], "#B15");
					Assert.IsNotNull (entry.Source, "#B16");
					Assert.AreEqual ("monotempsource", entry.Source, "#B17");
					Assert.IsNull (entry.UserName, "#B18");
				}
			} finally {
				if (!applicationLogExists) {
					if (EventLog.Exists ("Application"))
						EventLog.Delete ("Application");
				} else {
					if (EventLog.SourceExists ("monotempsource", "."))
						EventLog.DeleteEventSource ("monotempsource", ".");
				}
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:56,代码来源:EventLogTest.cs


示例17: CreateEventInstance

        private EventInstance CreateEventInstance(TraceEventType severity, int id) {
            // Win32 EventLog has an implicit cap at ushort.MaxValue
            // We need to cap this explicitly to prevent larger value 
            // being wrongly casted 
            if (id > ushort.MaxValue)
                id = ushort.MaxValue;

            // Ideally we need to pick a value other than '0' as zero is 
            // a commonly used EventId by most applications 
            if (id < ushort.MinValue)
                id = ushort.MinValue;
            
            EventInstance data = new EventInstance(id, 0);

            if (severity == TraceEventType.Error || severity == TraceEventType.Critical) 
                data.EntryType = EventLogEntryType.Error;
            else if (severity == TraceEventType.Warning)
                data.EntryType = EventLogEntryType.Warning;
            else                
                data.EntryType = EventLogEntryType.Information;

            return data;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:23,代码来源:EventLogTraceListener.cs


示例18: WriteEvent

 public void WriteEvent(EventInstance instance, byte[] data, Object[] values)
 {
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:3,代码来源:System.Diagnostics.EventLog.cs


示例19: LogEngineHealthEvent

 internal override void LogEngineHealthEvent(LogContext logContext, int eventId, Exception exception, Dictionary<string, string> additionalInfo)
 {
     Hashtable mapArgs = new Hashtable();
     IContainsErrorRecord record = exception as IContainsErrorRecord;
     if ((record != null) && (record.ErrorRecord != null))
     {
         mapArgs["ExceptionClass"] = exception.GetType().Name;
         mapArgs["ErrorCategory"] = record.ErrorRecord.CategoryInfo.Category;
         mapArgs["ErrorId"] = record.ErrorRecord.FullyQualifiedErrorId;
         if (record.ErrorRecord.ErrorDetails != null)
         {
             mapArgs["ErrorMessage"] = record.ErrorRecord.ErrorDetails.Message;
         }
         else
         {
             mapArgs["ErrorMessage"] = exception.Message;
         }
     }
     else
     {
         mapArgs["ExceptionClass"] = exception.GetType().Name;
         mapArgs["ErrorCategory"] = "";
         mapArgs["ErrorId"] = "";
         mapArgs["ErrorMessage"] = exception.Message;
     }
     FillEventArgs(mapArgs, logContext);
     FillEventArgs(mapArgs, additionalInfo);
     EventInstance entry = new EventInstance((long) eventId, 1) {
         EntryType = GetEventLogEntryType(logContext)
     };
     string eventDetail = this.GetEventDetail("EngineHealthContext", mapArgs);
     this.LogEvent(entry, new object[] { mapArgs["ErrorMessage"], eventDetail });
 }
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:EventLogLogProvider.cs


示例20: LogEvent

 private void LogEvent(EventInstance entry, params object[] args)
 {
     try
     {
         this._eventLog.WriteEvent(entry, args);
     }
     catch (ArgumentException)
     {
     }
     catch (InvalidOperationException)
     {
     }
     catch (Win32Exception)
     {
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:EventLogLogProvider.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Diagnostics.EventLog类代码示例发布时间:2022-05-26
下一篇:
C# Diagnostics.DataReceivedEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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