-
Notifications
You must be signed in to change notification settings - Fork 17
Logging
Alexey Busygin edited this page Mar 3, 2025
·
1 revision
The UPS shipping provider supports logging via ILogger
(other providers' support is in progress). You can pass an ILogger
instance using the corresponding constructor:
public UPSProvider(UPSProviderConfiguration configuration, ILogger<UPSProvider> logger);
public UPSProvider(UPSProviderConfiguration configuration, HttpClient httpClient, ILogger<UPSProvider> logger);
UPSProvider logs information at different levels:
- Error – Errors and exceptions
- Information – JSON requests and responses
- Debug – Additional details (e.g., acquiring a token)
🚨 Important: Some sensitive information is included in JSON requests and may require filtering on your side:
- UPS Account Number.
- Billings Address.
- Ship From Address.
- Ship To Address.
Consider using structured logging with a filtering mechanism, such as Serilog with Destructure.ByTransforming
, to prevent sensitive data from being logged.
If you are not using dependency injection, you can create an ILogger
instance using LoggerFactory
:
using (var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole(); // Adjust output as needed
}))
{
var upsProviderLogger = loggerFactory.CreateLogger<UPSProvider>();
rateManager.AddProvider(new UPSProvider(upsConfiguration, httpClient, upsProviderLogger));
...
}