|
|
|
|
|
|
|
Page Views :
|
2621
|
|
Downloads :
|
0
|
|
Rating :
|
Rate it
|
|
Level :
|
Intermediate
|
|
The Microsoft EIF is a bunch of assemblies for .Net that make your life easy when it comes to instrumenting your program, by this I mean tracing facilities, writing to the event log, and many other things.
As this is a quick guide I will tell you only how to get up and running with the Event Log and Windows Trace in the quickest way possible.
The EIF is capable of many things so having a good look at the docs is essential, but if you are like me you want to get using something as quickly as possible in its simplest form then work on the advanced features later , this guide may help.
I spent a few days trying to develop my own tracing and event log code but it just did not work right. For example try to write your own code that will automatically work out your assembly's path name and put it in the event log. I could not do it without some very messy work arounds.
Included with EIF is a thing called 'Windows Trace' this basically a binary log file that you can write to without worrying about performance. So even your production code can trace, and support staff can access this information.
Obtaining and Installing EIF
Go to http://www.microsoft.com/downloads/search.aspx and search for 'EIF'. Download and install 'Microsoft Enterprise Instrumentation Framework'. There is a very good seminar also available 'Using the Enterprise Instrumentation Framework' which I recommend you watch.
Using EIF in your code
Add References in your project to the following assemblies:
Microsoft.EnterpriseInstrumentation Microsoft.EnterpriseInstrumentation.Schema System.Configuration.Install
Add the following usings to any code that will use it :
using Microsoft.EnterpriseInstrumentation; using Microsoft.EnterpriseInstrumentation.Schema;
Add a new class to your project, I call mine EnterpriseInstrumentationProjectInstaller.cs this is used when registering your assembily.
Change the new class definition to :
[System.ComponentModel.RunInstaller( true)] public class EnterpriseInstrumentationProjectInstaller :
Microsoft.EnterpriseInstrumentation.ProjectInstaller
the class does not need any code in it.
These are the standard built in events you can raise:
AdminMessageEvent.Raise("message"); AuditMessageEvent.Raise("message"); ErrorMessageEvent.Raise("message", 0, "error code"); TraceMessageEvent.Raise("message");
Registering your assemibly and creating the configuration file
- Build your project
- Run the VS command prompt in output folder
- run InstallUtil.exe <assemally file name> (If you need to run this againg you can uninstall first with InstallUtil.exe /u <assemally file name>)
- A file 'EnterpriseInstrumentation.config' will be created, move it into project directory and include it in the project
- Set up post build event:
copy "$(projectdir)EnterpriseInstrumentation.config" "$(targetdir)EnterpriseInstrumentation.config" this will copy the configuration file to the target directo ry when you build.
Configure your project's EnterpriseInstrumentation.config
Add the required elements to the "defaultSoftwareElementFilter" filter
< filter name="defaultSoftwareElementFilter" description=" A default filter for the Software Element event sources."> <eventCategoryRef name="All Events"> <eventSinkRef name="traceSink" /> <eventSinkRef name="logSink" /> </eventCategoryRef> </filter>
This will use the event log and windows trace.
Enable Windows trace
When you install EIF windows trace is disabled by default to enable it edit C:\Program Files\Microsoft Enterprise Instrumentation\Bin\Trace Service\TraceSessions.config and set enabled="true".
Viewing the Windows trace file
Included in EIF is a sample 'C:\Program Files\Microsoft Enterprise Instrumentation\Samples\Trace Viewer\TraceViewer.exe' this can be used to view the trace file located at 'C:\Program Files\Microsoft Enterprise Instrumentation\Bin\Trace Service\Logs\TraceLog.log'
That's it; even if you only use EIF as described here it still offers better functionality then any code most people have time to write.
Cheers!
|
|
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post
Here.
|
|
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
|
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
|
|
|
|
|
|
|
|
|
|
|
|
|