Reputation: 23029
We are using Node.js server and have logs at Google Cloud Platform.
The problem is, if we do one log entry and we put object inside, which is serialized to multiline output, it is not "stacked".
So if we have object with 100 lines, it creates 100 line ouput into google which is really difficult to read and we are not able to "group" it.
In other services, the output was always stacked (loggly, logsene).
Do you know how to stack input? We are using Winston for logging (which has Console as one of output)
Upvotes: 11
Views: 2760
Reputation: 23029
This was the solution (PS: thanks to GordonHo to ping me on this question):
const winston = require('winston');
const config = require('config');
const _ = require('lodash');
function transportsMethod() {
const transports = [];
if (config.params.oneLineWinston === true) {
transports.push(new (winston.transports.Console)({
json: true,
stringify: (obj) => JSON.stringify(obj),
}));
} else {
transports.push(new (winston.transports.Console)({json: true}));
}
return transports;
}
const logger = new winston.Logger({
level: winstonLevel,
transports: transportsMethod(),
});
module.exports = logger;
Upvotes: 2
Reputation: 131
Try selecting in stackdriver 'winston_log'.
By default you are receiving the stdout, which gave me the same issues with multilines.
Upvotes: 2