Enterprise Library 5 logging class name
I'm trying to use the logging block of Enterprise library for our application and I'm wondering if there'开发者_JAVA技巧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.
Thanks
Spring.NET uses code like the following as part of creation of a static/shared logger for classes.
Private Shared ReadOnly _name As String = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + ": "
So you can copy/paste this around and it is performant because it only executes on class load.
However, I too am seeking the best way to include this in the logging statements. Entlib doesn't support the same hierarchical logger structure that Spring.NET uses. Using string concatenation just doesn't feel like the right way of doing this.
精彩评论