If you're looking to customize your filtering process, here's a possible solution:
function customRequestFilter(req, propName) {
if(propName !== "headers") return req[propName];
const { cookie, ...rest } = req.headers;
return rest;
}
For your winston configuration, consider the following options:
expressWinston.logger({
transports: [new winston.transports.Console()],
// requestWhitelist: ['headers'],
requestFilter: customRequestFilter,
format: winston.format.combine(
winston.format.colorize(),
winston.format.json()
),
meta: true, // optional: control whether you want to log the meta data about the request (default to true)
msg: "HTTP {{req.method}} {{req.url}}", // optional: customize the default logging message. E.g. "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}"
expressFormat: true, // Use the default Express/morgan request formatting. Enabling this will override any msg if true. Will only output colors with colorize set to true
colorize: false, // Color the text and status code, using the Express/morgan color palette (text: gray, status: default green, 3XX cyan, 4XX yellow, 5XX red).
ignoreRoute: function (req, res) {
return false;
}, // optional: allows to skip some log messages based on request and/or response
})
I trust this information proves beneficial for your needs. Best of luck!