First, you need to make your class interceptable. Refer to this
topic on how to do this.
On the configuration side, here are the steps:
1. Open your configuration file in the Enterprise Library Configuration Tool by right clicking on it and select Edit Enterprise Library Configuration.
2. Add the Policy Injection settings. (Blocks menu -> Add Policy Injection Settings)
3. Add a policy, give it any name you want.
4. Add a matching rule to that policy which would indicate what properties or methods that will be intercepted. For example, if you want to intercept a method named "Execute", you can add a Member Name Matching Rule and enter the string
"Execute" in the Member Names property. There are other matching rules which you can use so check those out.
5. Add the Logging Call Handler to the same policy. This will automatically add the Logging Settings in your config having a General category with a referenced Formatted Event Log Trace Listener. Now, if you add the General category in the Categories
property, this will then tells that for every method it intercepts, the logging will be done using the Formatted Event Log Trace Listener. There are other properties which you can configure and they are pretty much self explanatory.
You can check out the
Policy Injection documentation for more information.
Global Technologies and Solutions