Logging
The Migration SDK has built-in support for logging. SDK consumers can configure logging levels.NET, Python and add more logging providers (called handlers in Python).NET, Python.
Internally, the SDK will log every successfully Request/Response as an Information message with the Http Request Method, the Http Request Uri and the Http Response Status Code:
> Tableau.Migration.Net.NetworkTraceLogger: Information: HTTP GET "https://localhost/api/2.4/serverinfo" responded "OK".
It will also log every errored Request/Response as an Error message with the Http Request Method, the Http Request Uri and the Error Message:
> Tableau.Migration.Net.NetworkTraceLogger: Error: HTTP GET "https://localhost/api/2.4/serverinfo" failed. Error: "An error occurred while sending the request.".
As part of the included tracings, it is possible to configure the level of details for each log message by setting the following configuration parameters:
- Network.HeadersLoggingEnabled: Indicates whether the SDK logs request/response headers. The default value is disabled.
- Network.ContentLoggingEnabled: Indicates whether the SDK logs request/response content. The default value is disabled.
- Network.BinaryContentLoggingEnabled: Indicates whether the SDK logs request/response binary (not textual) content. The default value is disabled.
- Network.ExceptionsLoggingEnabled: Indicates whether the SDK logs network exceptions. The default value is disabled.
The Migration SDK supports logging with built-in providers like the one described in Python Logging docs.
SDK default handler
The SDK adds a StreamHandler to the root logger by executing the following command:
logging.basicConfig(
format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level = logging.INFO)
Overriding default handler configuration
To override the default configuration, set the force
parameter to True
.
logging.basicConfig(
force = True,
format = '%(asctime)s|%(levelname)s|%(name)s -\t%(message)s',
level = logging.WARNING)
Note
See Logging Configuration for advanced configuration guidance.