I have few questions about Node.js Bunyan logging. I'm kinda new the bunyan logging, so please I apologize if i ask any laymen questions.
I'm trying to stream bunyan log output in json format. Primarily in a file and I have plans to stream it a remote host.
Here's a simple code that i'm trying:
var bunyan = require("bunyan");
var logger = bunyan.createLogger({
name: "testApp",
streams: [
{
path: "bunayan.log"
}
],
src: true
});
logger.info("Data sent to file");
The output is:
{"name":"testApp","hostname":"xxx.xxx.com","pid":14124,"level":30,"msg":"Data sent to file","time":"2018-05-07T19:14:15.866Z","src":{"file":"/path/to/file/banyan_test.js","line":11},"v":0}
So, i'm trying to format the output like this;
- Override the hostname or set a desired hostname
- Change "level":30 to "level":"info"
- Change the format of the time json object
- Add additional json object for example:
"attr4": "value"
- Is there any way to change the default json object name such as
time
totimestamp
I couldn't find any simple or clear example of doing any of the above change. Can anyone please show me some examples to start with? Doesn't need to be all points together but at least a head start or any helpful documentation.