logging block capturing class name

Topics: Logging Application Block
Jul 20, 2010 at 6:33 PM


I'm trying to use the logging block of Enterprise library for our application and I'm wondering if there's a way for the logger to automatically log the Class name that it is called from?

I could manually insert the class name in the message when calling logger.write but I want to know if there's another way of doing this.



Jul 21, 2010 at 8:13 AM

One way I can think of is to use Policy Injection with using Logging Call Handler. Adding the token {property(TypeName)} in your formatter, this will let you log the class name whenever a method is invoked from that class. Here a post from Unity that I think may help you with this http://unity.codeplex.com/Thread/View.aspx?ThreadId=215690.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.

Jul 21, 2010 at 7:16 PM

Thanks for the reply, will look into this.