I am trying to log few request and response parameters for debug purpose. I guess Global policy fragments with message-completed state is the best/suitable approach for that. But response status code and few context variables are not logged whenever customize error response executes. I need to log response status code for all transactions. can you help me? Also i believe Global policy fragments are asynchronous in nature, if not i have to do the logging asynchronously so not to increase transaction time. what is the best way to do that?
The global policies are not asynchronous as they run prior to the service being resolved and then after the service policy has executed. If you are looking for an asynchronous method you can look to use Custom Audit Sink Policy with some logic that looks for a trigger like debug in a variable of the policy. If you still want to do it inline of the policy we have seen some customers have in the main policy a static audit detail writing to the logs with all the important information.