How to save pipe through bunyan CLI tool logs to log file instead of json format

525 Views Asked by At

How I can save logs generated by bunyan CLI tool by using command to run server node . | bunyan to server.log instead of json format in server.log file.

On console logs:- [2018-05-14T12:28:01.465Z] INFO: sampleApplication/12840: hi

server.log:- {"name":"sampleApplication","pid":12840,"level":30,"msg":"hi","time":"2018-05-14T12:28:01.465Z","v":0}

How can both be same in console and server.log?

1

There are 1 best solutions below

0
On

You can try add different streams in your bunyan init config:

bunyan.createLogger({
    name: 'name',
    streams: [{
      path: './logs/file.log'
    }, {
        level : 'debug',
        stream : process.stdout
    }]
  });