Enable SignalR Logging with One Simple Line

It is easy to think that SignalR works within a black box, but if you are deploying JavaScript clients, here is an EASY trick to learning what is happening underneath the scenes. This is especially helpful when debugging transport negotiation issues.

Before you start your connection, add this ONE line of code:

$.connection.hub.logging = true;
$.connection.hub.start();

Tada! You have logging in your browser console:

SignalR logging example

If you’re encountering issues on older browsers, check out my article on SignalR AbortController issues for a common workaround.

Kevin Griffin - Microsoft MVP and .NET Expert

About Kevin

Kevin Griffin has been running production .NET applications and teaching developers for over two decades. A 16-time Microsoft MVP specializing in ASP.NET Core and Azure, Kevin brings real-world experience from his own SaaS products alongside his consulting work at Swift Kick. He's hosted the Hampton Roads .NET User Group since 2009 and founded RevolutionVA, the nonprofit behind Hampton Roads DevFest. Kevin's talks blend hard-won lessons from production systems with practical advice you can use Monday morning.