开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜