Using ConsoleListener you can listen to JavaScript Console messages with different levels: DEBUGLOG,WARNING and ERROR. To start receiving Console messages you need to register ConsoleListener for a specified Browser instance. For example:

C#

browser.ConsoleMessageEvent += delegate(object sender, DotNetBrowser.Events.ConsoleEventArgs e)
{
    Console.WriteLine("Message: " + e.Message);
};

VB.NET

AddHandler browser.ConsoleMessageEvent, Sub(o As Object, e As ConsoleEventArgs) 
    Console.WriteLine("Message: " + e.Message)
End Sub


Example

 

MainWindow.xaml


<Window x:Class="ConsoleListenerSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpf="clr-namespace:DotNetBrowser.WPF;assembly=DotNetBrowser"
        Title="MainWindow" Height="350" Width="525">
    <Grid Name="mainLayout">
        <wpf:WPFBrowserView  Name="browserView" />
    </Grid>
</Window>


C#

MainWindow.xaml.cs


using DotNetBrowser;
using DotNetBrowser.WPF;
using System;
using System.Windows;

namespace ConsoleListenerSample
{

   /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            browserView.Browser.
                LoadURL("http://www.google.com");
            browserView.Browser.ConsoleMessageEvent 
                +=Browser_ConsoleMessageEvent;
            browserView.Browser.ExecuteJavaScript
                ("console.error(\"Error message\");");
        }

        private void Browser_ConsoleMessageEvent
            (object sender, DotNetBrowser.Events.ConsoleEventArgs e)
        {
            Console.WriteLine("Message: " + e.Message);
        }
    }
}



VB.NET

MainWindow.xaml.vb

Imports DotNetBrowser.Events

Namespace ConsoleListenerSample
    Class MainWindow
        Sub New()
            InitializeComponent()
            browserView.Browser.LoadURL("http://www.google.com")
            AddHandler browserView.Browser.ConsoleMessageEvent, AddressOf Browser_ConsoleMessageEvent
            browserView.Browser.ExecuteJavaScript("console.error(""Error message"");")
        End Sub

        Private Sub Browser_ConsoleMessageEvent(sender As Object, e As ConsoleEventArgs)
            Console.WriteLine("Message: " + e.Message)
        End Sub
    End Class
End Namespace