Currently, each component of a multi-tiered system logs all function invocations using PostSharp.
e.g. an application call to a WCF service might prompt calls to a DataService (in process) and an AuditService (via NServiceBus)
Application -> CaseService: getCaseWithAppointments() (via WCF)
CaseService -> DataService: getCaseById()
CaseService -> DataService: getCaseAppointments()
CaseService -> AuditService: logCaseAccess() (via NServiceBus)
This will result in four rows being written to a log table, but when looking at the log table later, it is not possible to identify that the logCaseAccess()
call was called as part of the enclosing getCase()
application call.
It would be much more useful if these four rows could be identified as a group.
I can see how it would be possible for the application to generate a Guid which could be passed as a parameter to each subsequent call, but wouldn't this only be possible by changing the signatures for every function across the solution? The solution already includes more than 20 services comprising over 200 OperationContracts, so this would represent considerable effort.
Is there a way of modifying each of the services so that each of their functions knew to expect an additional parameter (the Guid) and to pass that on to any successive calls (perhaps using PostSharp method boundaries)?
I have read this (Is there a way in Log4Net or NLog (or some other logger) to output logs in an execution-stack-nested XML or JSON format?), but unfortunately it did not address the distributed (and multi-threaded) nature of my requirement: