For setting up and retrieving log entries using Selenium, Chrome, and 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 for 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());
}