Using Caller Info Attributes in C# 5 Improves Logging

added by pardogo
6/13/2012 8:32:45 AM

5 Kicks, 360 Views

The problem of passing current method details haunted my team and me when we were asked to add logging to every available business layer method in a two year old project, that had no logging and empty try { } catch { } blocks. We eventually worked around it by using a mix of reflection and string literals to get the current method name. But in my guts I hated the fact that I had to use reflection to do logging. This was 5 years ago using C# 2.0. Come VS 2012 and C# 5, we will have access to three attributes that do specifically the task that we had hacked around then


1 comments

timbolt8
6/13/2012 8:51:22 AM
Great article. I have used log4net in many of my projects and find it to fit my needs every time :)