Developers Program

Logging API Calls with .NET SDK

Published: August 22 2006, 3:02:00 PMยทUpdated: July 26 2022, 1:31:24 PM

Products

Question

How can I log the API call request and response using the .NET SDK?

Answer


Detailed Description

Here is a C# sample code to log your call request and response using the .NET SDK:

public ApiContext GetContext()
{
context = new ApiContext();
//set the your credentials
context.ApiCredential.eBayToken = "token";
context.SoapApiServerUrl = "url";

//set the version
context.Version = "1131";

//set the logging
string logFile = "LogFile.txt";
context.ApiLogManager = new ApiLogManager();
context.ApiLogManager.ApiLoggerList.Add(new FileLogger(logFile, true, true, true));
context.ApiLogManager.EnableLogging = true;

return context;
}

Although logging adds a little bit of an overhead to your application, it becomes fairly easy to track down errors.


Additional Resources
How well did this answer your question?