Skip to content
Advertisement

Can Winston Logger be used on the front-end for logging?

I am creating full mean stack app with

NodeJs , Angular 6 , ExpressJs and MongoDB

I have managed to create a server and its working perfectly, instead of using console.log when logging errors in my app I have decided to use Winston Logger here is what I have now

Server side

JavaScript

Note: Winston in server side works perfectly

Client-Side

I want to use winston in my client side angular 6 app .

Example: in one of my components i have this.

JavaScript

As you can see I am using console.log(review) , Instead of console log I would like to use Winston .

How to use Winston logger in client-side ? am newbie to all this stuff any help will be apreciated.

Advertisement

Answer

Yeah it is possible, however default transport for browser is very limited. I recommend to use https://www.npmjs.com/package/winston-transport-browserconsole

npm install winston-transport-browserconsole -S

It is easy to use and supports logging json objects:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement