I am running a nodeJS server on Ubuntu 14.04 in Google Compute Engine. I want to use google cloud logging for my application so I installed google fluentd logging agent as per https://cloud.google.com/logging/docs/agent/installation
I used winston and winston-syslog for writing logs. Here is the code.
var winston = require('winston');
var winstonsyslog = require('winston-syslog').Syslog;
var options = {
json : true
};
winston.add(winston.transports.Syslog, options);
When I am writing a log using
winston.log('info', "27", { anything: 'This is metadata' });
I am getting
{
metadata: {…}
textPayload: "May 14 10:47:44 localhost node[7633]: {"anything":"This is metadata","level":"info","message":"27"}"
insertId: "..."
log: "syslog.local0.info"
}
How to get structPayload instead of textPayload which displays log as JSON instead of String.