1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-08 08:26:20 +00:00
This commit is contained in:
Jkorf 2022-01-17 13:58:51 +01:00
parent e33e7c6775
commit cdbc0ba215
2 changed files with 14 additions and 14 deletions

View File

@ -7,16 +7,16 @@ The library offers extensive logging, for which you can supply your own logging
Logging is based on the `Microsoft.Extensions.Logging.ILogger` interface. This should provide ease of use when connecting the library logging to your existing logging implementation.
### Serilog
## Serilog
To make the CryptoExchange.Net logging write to the Serilog logger you can use the following methods, depending on the type of project you're using. The following examples assume that the `Serilog.Sinks.Console` package is already installed.
#### Dotnet hosting
### Dotnet hosting
With for example an ASP.Net Core or Blazor project the logging can be added to the dependency container, which you can then use to inject it into the client. Make sure to install the `Serilog.AspNetCore` package (https://github.com/serilog/serilog-aspnetcore).
<Details>
<Summary>
<b>Using ILogger injection</b>
Using ILogger injection
</Summary>
<BlockQuote>
@ -71,7 +71,7 @@ public class BinanceDataProvider
<Details>
<Summary>
<b>Using Add[Library] extension method</b>
Using Add[Library] extension method
</Summary>
<BlockQuote>
@ -132,7 +132,7 @@ public class Startup
</BlockQuote>
</Details>
#### Console application
### Console application
If you don't have a dependency injection service available because you are for example working on a simple console application you can use a slightly different approach.
*Configuring Serilog as ILogger:*
@ -159,7 +159,7 @@ var client = new BinanceClient(new BinanceClientOptions
The `BinanceClient` will now write the logging it produces to the Serilog logger.
### Log4Net
## Log4Net
To make the CryptoExchange.Net logging write to the Log4Net logge with for example an ASP.Net Core or Blazor project the logging can be added to the dependency container, which you can then use to inject it into the client you're using. Make sure to install the `Microsoft.Extensions.Logging.Log4Net.AspNetCore` package (https://github.com/huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore).
Adding `AddLog4Net()` in the `ConfigureLogging` call will add the Log4Net implementation as an ILogger which you can inject into implementations. Make sure you have a log4net.config configuration file in your project.
@ -201,10 +201,10 @@ public class BinanceDataProvider
If you don't have the Dotnet dependency container available you'll need to provide your own ILogger implementation. See [Custom logger](#custom-logger).
### NLog
## NLog
To make the CryptoExchange.Net logging write to the NLog logger you can use the following ways, depending on the type of project you're using.
#### Dotnet hosting
### Dotnet hosting
With for example an ASP.Net Core or Blazor project the logging can be added to the dependency container, which you can then use to inject it into the client you're using. Make sure to install the `NLog.Web.AspNetCore` package (https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5).
Adding `UseNLog()` to the `CreateHostBuilder()` method will add the NLog implementation as an ILogger which you can inject into implementations. Make sure you have a nlog.config configuration file in your project.
@ -247,7 +247,7 @@ public class BinanceDataProvider
If you don't have the Dotnet dependency container available you'll need to provide your own ILogger implementation. See [Custom logger](#custom-logger).
### Custom logger
## Custom logger
If you're using a different framework or for some other reason these methods don't work for you you can create a custom ILogger implementation to receive the logging. All you need to do is create an implementation of the ILogger interface and provide that to the client.
*A simple console logging implementation (note that the ConsoleLogger is already available in the CryptoExchange.Net library)*:

View File

@ -74,7 +74,7 @@ The options provided in the SpotApiOptions are only applied to the SpotApi (`cli
## CryptoExchange.Net options definitions
All clients have access to the following options, specific implementations might have additional options.
**Base client options**
**Base client options**
|Option|Description|Default|
|------|-----------|-------|
|`LogWriters`| A list of `ILogger`s to handle log messages. | `new List<ILogger> { new DebugLogger() }` |
@ -83,13 +83,13 @@ All clients have access to the following options, specific implementations might
|`ApiCredentials`| The API credentials to use for accessing protected endpoints. Typically a key/secret combination. Note that this is a `default` value for all API clients, and can be overridden per API client. See the `Base Api client options`| `null`
|`Proxy`|The proxy to use for connecting to the API.| `null`
**Rest client options (extension of base client options)**
**Rest client options (extension of base client options)**
|Option|Description|Default|
|------|-----------|-------|
|`RequestTimeout`|The time out to use for requests.|`TimeSpan.FromSeconds(30)`|
|`HttpClient`|The `HttpClient` instance to use for making requests. When creating multiple `RestClient` instances a single `HttpClient` should be provided to prevent each client instance from creating its own. *[WARNING] When providing the `HttpClient` instance in the options both the `RequestTimeout` and `Proxy` client options will be ignored and should be set on the provided `HttpClient` instance.*| `null` |
**Socket client options (extension of base client options)**
**Socket client options (extension of base client options)**
|Option|Description|Default|
|------|-----------|-------|
|`AutoReconnect`|Whether or not the socket should automatically reconnect when disconnected.|`true`
@ -101,13 +101,13 @@ All clients have access to the following options, specific implementations might
|`MaxResubscribeTries`|The maximum amount of tries for resubscribing after successfully reconnecting the socket|5
|`MaxConcurrentResubscriptionsPerSocket`|The maximum number of concurrent resubscriptions per socket when resubscribing after reconnecting|5
**Base Api client options**
**Base Api client options**
|Option|Description|Default|
|------|-----------|-------|
|`ApiCredentials`|The API credentials to use for this specific API client. Will override any credentials provided in the base client options|
|`BaseAddress`|The base address to the API. All calls to the API will use this base address as basis for the endpoints. This allows for swapping to test API's or swapping to a different cluster for example.|Depends on implementation
**Options for Rest Api Client (extension of base api client options)**
**Options for Rest Api Client (extension of base api client options)**
|Option|Description|Default|
|------|-----------|-------|
|`RateLimiters`|A list of `IRateLimiter`s to use.|`new List<IRateLimiter>()`|