Logging

This guide describes how to configure logging for the library.

The root cause of many issues can be detected by analyzing DotNetBrowser log messages.

By default, logging in DotNetBrowser is disabled. But if you encounter an issue or observe some unexpected behavior, we recommend you to do the following: 1. Configure DotNetBrowser to save all log messages to a file. 2. Reproduce the issue. 3. Submit a ticket with the collected log messages for further investigation.

Levels of logging

DotNetBrowser supports the following logging levels: All > Verbose > Information > Warning > Error > Critical > Off.

The level Off can be used to turn off logging completely, and All is used to enable logging of all messages, including messages from Chromium.

You can change the logging level using the LoggerProvider.Instance.Level property.

For more information on levels of logging, refer to MSDN description.

Example: Setting Logging Level

To save all log messages with the logging level Verbose and higher, use the DotNetBrowser Logging API as shown in the code sample below:

using DotNetBrowser.Logging;
//...
LoggerProvider.Instance.Level = SourceLevels.Verbose;

Logging to a file

To print all log messages to a file, use the LoggerProvider.Instance.FileLoggingEnabled property of DotNetBrowser Logging API as shown in the code sample below:

using DotNetBrowser.Logging;
//...
LoggerProvider.Instance.FileLoggingEnabled = true;
LoggerProvider.Instance.OutputFile = "C:\\log.txt";

In the sample above, the value of the LoggerProvider.Instance.OutputFile property represents an absolute or relative path to a file where the log messages are stored.

Go Top