Trying to log the time When Method is Called and When its completed its operation and return the values Exit Time.
this i am trying in N-tier architecture.Like
i. Service Layer
ii. Business layer
iii. Data Layer
Data Layer defined a Method A
, which is consumers by the Bushiness layer method B
. Business layer method B
is Called by Service Layer method D
.
the Log Will be Like
Service Method D Called At {Time Stamp}
Business Layer Method B Called At {Time Stamp}
Data Layer Method called at {Time Stamp}
Data Layer Returned Response at {Time Stamp} .Exiting
Business Layered Received response from Data layer at {Time Stamp}. Exiting
Service Layered Received exception from Business layer Method. at {Time Stamp}. Exiting
Currently i passing a additional string builder object for this to maintain log and respective time . appending current scope and Time Stamp.
Can i automate this process by dependency injection , so i can avoid passing that extra string builder object.or there is better solution for this.
There are different approaches you can use to get the desired functionality.
One approach is interception as (for example) Unity provides (see http://msdn.microsoft.com/en-us/library/dn178466(v=pandp.30).aspx)
Another approach is to use some kind of aspects. See Postsharp for an example (http://www.postsharp.net/)