Logging in nodejs using bunyan logger

后端 未结 3 1573
Happy的楠姐
Happy的楠姐 2021-01-15 12:39

I am initializing the bunyan logger in my nodejs code as below:

var log = bunyan.createLogger({
    name: \'myapp\',
    stream: process.stdout,
    level: \         


        
3条回答
  •  花落未央
    2021-01-15 13:31

    process.stdout is for Logging on Console.
    

    If you want to log on a file you need to provide different streams.

    var log = bunyan.createLogger({ 
                    name: 'myapp',
                    streams: [
                        {
                            level: 'trace',
                            stream: process.stdout
                        },
                        {
                            level: 'warn',
                            path: './filename.log'
                        }
                    ]
                });
    

提交回复
热议问题