Find the answer to your question
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?
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.
Here is a C# sample that logs the request and response for GeteBayOfficialTime:
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);
FileStream fileStream = null;
StreamWriter writer = null;
string fileName = "log.txt";
fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
writer = new StreamWriter(fileStream);
writer.WriteLine(call.SoapRequest + "\r\n");
How well did this answer your question?
Answers others found helpful