C# Selenium access browser log

To set-up and retrieve the log entries with Selenium / Chrome / C# :

ChromeOptions options = new ChromeOptions();
options.SetLoggingPreference(LogType.Browser, LogLevel.Warning);

var driver = new ChromeDriver(options);

driver.Navigate().GoToUrl("http://stackoverflow.com");

var entries = driver.Manage().Logs.GetLog(LogType.Browser);
foreach (var entry in entries) {
    Console.WriteLine(entry.ToString());
}

And with Firefox:

FirefoxOptions options = new FirefoxOptions();
options.SetLoggingPreference(LogType.Browser, LogLevel.Warning);

var driver = new FirefoxDriver(options);

driver.Navigate().GoToUrl("http://stackoverflow.com");

var entries = driver.Manage().Logs.GetLog(LogType.Browser);
foreach (var entry in entries) {
    Console.WriteLine(entry.ToString());
}