Skip to main content
Published: February 21 2008, 2:30:00 PMUpdated: August 04 2022, 9:31:18 PM

I want to go live with my application in production and I want to enable logging only certain calls to reduce overhead.  How can I do that with the .NET SDK?

Summary 

If you do not want to log all the requests and responses, then you can use the SoapRequest and SoapResponse properties of the API call object to get the call request and response and log it to a file.
 


Detailed Description

Here is a C# sample that logs the request and response for GeteBayOfficialTime:

 

using  System;
using System.IO;
using eBay.Service.Call;
using eBay.Service.Util;
using eBay.Service.Core.Sdk;
using eBay.Service.Core.Soap;

private void GeteBayOfficialTime()
{

     ApiContext context = new ApiContext();
     context.ApiCredential.eBayToken = "Your Token";
     
     //Server URL for Sandbox
    
context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";
     //For production, the url is https://api.ebay.com/wsapi"

    
GeteBayOfficialTimeCall call = new GeteBayOfficialTimeCall(context);
     call.Execute();
     FileStream fileStream = null;
     StreamWriter writer = null;
     string fileName = "log.txt";
     fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);

     writer = new StreamWriter(fileStream);
     writer.BaseStream.Seek(0, SeekOrigin.End);
     //log request
    
writer.WriteLine(call.SoapRequest + "\r\n");
     writer.Flush();
     //log response
    
writer.WriteLine(call.SoapResponse);
     writer.Flush();
     writer.Close();
}

 

 

How well did this answer your question?
Answers others found helpful