Diagnostics
The Web SDK also includes a diagnostics client. This can be useful for auditing and debugging.
The diagnostics client is static and will be shared along all IWebMClient instances.
Supported diagnostics
The diagnostics client supports the following features:
-
Setting a (custom) logger where all entries will be logged to
-
Logging HTTP requests and responses. This can be set to:
-
None- no HTTP requests and responses will be logged -
Minimal- only the request method, request URL and the response status code will be logged. -
Full- full log of the requests and responses, including their payload.
-
-
Logging caching events: for example, when an entry was added or removed from the cache
-
Logging resilience events: for example, timeouts, retries, throttling, and so on.
-
Logging warnings: when the SDK notices unexpected behaviour
Setting up logging
To enable logging it is required to set a logger on the DiagnosticsClient. It is possible to set any ILogger implementation. The ConsoleLogger is an out-of-the-box ILogger implementation that writes to the console. The ConsoleLogger can be found under the stylelabs.M.Sdk.Models.Logging namespace.
Be sure to set the log level to debug, because most of the entries will be logged under debug.
The DiagnosticsClient can be found under the Stylelabs.M.Sdk.WebClient.Diagnostics namespace.
Logging HTTP requests and responses example
In the following example an Asset entity is fetched from a newly created client with HTTPLogging set to Full.
This will result in the following requests and responses: