This project has moved and is read-only. For the latest updates, please go here.

MEF Attribute Logger Tool Instructions


My MEF (Managed Extensibility Framework) Logger tool is designed as a simple way to add logging capabilities to your application.   My tool requires the installation of PostSharp 2.1 code injector and Microsoft's Enterprise logger components, as well as some version of Visual Studios 2010 on your computer.  However, if you are not going to use the logging features of Enterprise logger, then you can skip the installation of this prerequisite.



  1. Visual Studio 2010
  2. PostSharp 2.1
  3. Enterprise Library 5.0 (Free)



  1. Install 'MEFLogger'.
  2. Install 'Enterprise Library 5.0' (Optional)


How to Use:

Using Visual Studios 2010, open up the application you want to update with the logging capabilities.  Add the following four assemblies into your application, using Visual Studio's 'Add Reference' tool;



Then, if you are going to use Microsoft's Enterprise logger with this component, then add the following two assemblies;



If you chose the correct assemblies, your 'References' should look like the picture below;



For this example, I am setting up the MEF logger to use Microsoft's Enterprise logger component.  Furthermore, since I am using custom category groups, I am going to tell the MEF logger what the names are for these groups.  In my application, I have decided to place this setting in the App.cs 'Application_StartUp' entry point.  However, in your own application you can add this to your opening constructor method.  The important thing to notice in the picture below is the name of category groups, which you create within app.config file.


Next, you need to add the MEF Logger attribute to the start of your application.  Make sure this is outside the namespace, as shown in the picture below.  Also, verify your applications namespace is set in the 'AttributeTargetTypes' property, as shown with the blue arrow.


Finally, if you want to manually log some message into the logger, use the code as shown below.  You can place this code anywhere in your application, since the Enterprise component use 'Unity' to obtain the proper instances.  In my example below, I created the LogEntry instance, with the message I want logged into the MEF Logger.  Then, I updated the 'Categories' to specifically tell the MEF Logger to place this message into the 'General' listener.


Last edited Jan 5, 2013 at 6:38 AM by berben11, version 5


No comments yet.