Logging diagnostic information plays a key part for any application. The QuickBooks Online .NET SDK allows you to configure logging in theconfigfile. You can modify the settings or override them without having to redeploy the application.
Configure trace logging using the following steps:
1. Add reference
In Visual Studio make sure that the Intuit.Ipp.Diagnostics
assembly is referenced. The assembly uses System.Trace
as the default logger to log messages.
2. Update the configuration file
Include the following lines in the application settings file (Appsettings.json) and define the local file system (folder) path to store the logs:
1 2 3 4 5 6 | "Logger":{ "RequestLog":{ "EnableLogs": "true", "LogDirectory": "C:\\IdsLogs" } } |
TraceLevel | Config File Value | Description |
Off | 0 | Do not log tracing and debugging messages. |
Error | 1 | Log only error-handling messages. |
Warning | 2 | Log warnings and error-handling messages. |
Info | 3 | Log informational messages, warnings, and error-handling messages. |
Verbose | 4 | Log all debugging and tracing messages. |
The .NET SDK supports the logging of request and response XML files. These logs help with application debugging and can be saved on a local file system. The SDK allows you to define request and response log settings in the configuration file. The following code snippets show how to enable request and response logging:
1.. Configure request and response log
Set the EnableLogs
property of RequestLog
to true:
1 2 3 4 5 6 | "Logger":{ "RequestLog":{ "EnableLogs": "true", "LogDirectory": "C:\\IdsLogs" } } |
Note
Note
The SDK allows you to override the default logger settings. If a logger is not defined in the configuration file, the SDK uses the default logger System.Trace. For detailed information, see Configuration.