Add custom fields
Enado95 opened this issue · 3 comments
Enado95 commented
Is there an option to add customer field?
Like for example I want to add a username field to see made the request to me api.
I already have in the msg like this:
msg: (req, res) => 'Test' + (res.statusCode == 401 ? ' ' : ` Username: ${req.user.perferred_username}`)
But its quite challenging to search.
dezoito commented
Have you tried the dynamicMeta: function(req, res) { return [Object]; }
option?
I am using it to write the unique request Id to the logs:
app.use(expressWinston.logger({
transports: [
new winston.transports.File({
....
}),
],
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json(),
),
dynamicMeta: function(req, res) {
return { reqId: req.id };
}
}));
Enado95 commented
Thanks I'll check it out