Skip to main content
Published: August 19 2014, 9:33:00 AMUpdated: July 29 2022, 10:42:32 AM

Exception based logging with .NET SDK


With .NET SDK, you can do logging conditionally.  You can log the SOAP request and response based on API Error Codes, SDK Exceptions and / or Http Status codes.

Detailed Description

Here is an example of how to set exception based logging.
© 2007-2014 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 -

//Create the API context object

ApiContext context = new ApiContext();

//Set the Credentials
context.ApiCredential.ApiAccount.Developer = 'devID';
context.ApiCredential.ApiAccount.Application = 'appID';
context.ApiCredential.ApiAccount.Certificate = 'certID';
context.ApiCredential.eBayToken = 'token';

//Set the URL
context.SoapApiServerUrl = ''; 

//Set the version
context.Version = '485';

//API Error codes for logging
StringCollection errorCodes = new StringCollection();
// Internal error to the application
errorCodes.Add('931'); // Invalid Token Error

//Http Status Codes for logging

Int32Collection httpCodes = new Int32Collection();





//Trigger Exceptions for logging

TypeCollection exceptions = new TypeCollection();



//Create the Exception Filter

ExceptionFilter exFilter = new ExceptionFilter();

exFilter.TriggerErrorCodes = errorCodes;

exFilter.TriggerExceptions = exceptions;

exFilter.TriggerHttpStatusCodes = httpCodes;

// Set logging
Context.ApiLogManager = newApiLogManager();
context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger('Messages.log', true, true, true));
context.ApiLogManager.EnableLogging = true;

//Set the filter to log messages only for specified errors / exceptions
context.ApiLogManager.MessageLoggingFilter = exFilter;


Additional Resources


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

Got thoughts? Click the feedback button – your insights help us improve!