Wiring up client side logs into c#/node.js logging frameworks
Around a year ago I joined a new team where I work, and this team was starting to undertake a full rewrite of their code. We were going from a full c#/mvc app to a tiny c# api, and a very big SPA.
I started Bingling around and I stumbled across jsnlog. JSN log lets you quickly wire up your client side logs to your server. I have been able to get PR’s into the code base and the guy behind it has been very friendly to me when I have had questions.
When you install the nuget package it drops this into your app_start.
The whole thing is a html handler, so this code just simply makes sure the handler gets the first route.
When you are going to render a page you have to inject this razor:
Then whenever you want to log anything client side you can do the following.
You can also set jsnlog as the global js error handler.
The docs are quite good, and it seems to work fine as a commonjs module (since we browserify things). The tool is super configurable through the web.config, and you can change the url it logs to.
JSNLog is a great way to get your client side logs into your server infrastructure fast. The library has fantastic support for node, and every major .NET logging framework. Someone in the community even made a php plugin! The examples are endless
Overall I am really pleased with JSNLog, it filled a need that I needed, and it meant I was able to focus on what I did best, not figure out how logging worked.