Posted by: R Manimaran | July 7, 2010

Using Microsoft Enterprise Library Tracing Feature

Using Enterprise Library Tracer in your main methods will help to check the time taken by each method call.  We can easily identify the method which is taking more time and do a Performance fix. This will log the elapsed time on each method.

In the project add reference to “Microsoft.Practices.EnterpriseLibrary.Logging”

Add the using statement

using Microsoft.Practices.EnterpriseLibrary.Logging;

In each method use the tracer as shown.

private void MyMethod()


using (new EntLog.Tracer(“Entering the MyMethod”))


//Your code for MyMethod goes here



Add Config file Settings.

  • If you are using windows/Console appliation add a App.Config file. If you are using the Web application use the web.config file.
  • Open the .config file using Microsoft Enterprise Library configuration tool.
  • the File and add the new Logging Application Block as shown

  • Now the Logging details and Enterprise Library dll details are added in the Config file.

Check the Tracing:

  • After the code run, the logging details is get stored in the windows eventlog.

  • From this we can conclude the above method takes 8.941 seconds to execute.Based on the above you can do the performance fix.

Note: You can disable the Logging by changing the attribute tracingEnabled=”false”


    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s


    %d bloggers like this: