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?
Asked
Active
Viewed 1,410 times
2

Mohammad Ranjbar Z
- 1,487
- 1
- 10
- 20
-
1amend the default console transport like so: https://github.com/winstonjs/winston#common-transport-options – LostJon Jul 19 '21 at 16:39
-
Yeah console transport is good, but I want to use my log files – Mohammad Ranjbar Z Jul 19 '21 at 20:31
2 Answers
4
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-viewer
tail -f logFile.log | winston-log-viewer
Or
tail -f logFile.log | npx winston-log-viewer

Mohammad Ranjbar Z
- 1,487
- 1
- 10
- 20
1
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:

Gagan
- 1,267
- 3
- 18
- 28