Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am having a scenario in my WCF application where I need to log the requests into the database upon exception I have stored my request in a dictionary and used IsFault to check whether my request is fault, if it is fault than I have logged it into the database
C#
 public static string key;
Dictionary<string , string> actionToReplyAction;
String value  = "";
public NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

public void AfterReceiveReply(ref Message reply, object correlationState)        
{
    if (reply.IsFault)
    {
        string requestAction = (string)correlationState;
        _logger.Debug("Request  :::: " + key);
        _logger.Debug("Response :::: " + reply.ToString());
    }
}

public object BeforeSendrequest(ref Message request, IClientChannel channel)
{
    key = request.ToString();

    return null;
}


How can I log the Request whenever the response is Lost. I am new to WCF: if you could give me sample code it would be helpful.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900