In Bunyan logger we can see the log files like this:
tail -f sample.log | bunyan and show the logs colorful and show json objects pretty, but I couldn't find some thinkg like that solution in Winston logger, any body has idea about that?
Is there a way to show winston log files like we show it in bunyan CLI?
1.8k Views Asked by Mohammad Ranjbar Z At
2
There are 2 best solutions below
0
On
Similar to winston-log-viewer I had created munia-pretty-json and using it for many projects. You can visualize any json log at console.
npm install -g munia-pretty-json
Your json data (app-log.json)
{"time":"2021-06-09T02:50:22Z","level":"info","message":"Log for pretty JSON","module":"init","hostip":"192.168.0.138","pid":123}
{"time":"2021-06-09T03:27:43Z","level":"warn","message":"Here is warning message","module":"send-message","hostip":"192.168.0.138","pid":123}
Run the command:
munia-pretty-json app-log.json
Or tail the json file:
tail -f app-log.json | munia-pertty-json
Here is readable output on console:
You can format the output with the template. The default template is '{time} {level -c} {message}'
Using template:
munia-pretty-json -t '{module -c} - {level} - {message}' app-log.json
Output:


I wrote a tiny npm package based on Bunyan CLI for pretty printing winston logs, you can use that in this way:
npm i -g winston-log-viewertail -f logFile.log | winston-log-viewerOr
tail -f logFile.log | npx winston-log-viewerhttps://github.com/mohammadranjbarz/winston-log-viewer