Log Provider
logProvider
选项用于配置日志管理。
示例使用的 winston 来配置。
var winston = require('winston');
var proxyMiddleware = require("http-proxy-middleware");
var options = {
target: 'http://localhost:3000',
logProvider: function (provider) {
return winston;
}
};
var proxy = proxyMiddleware('/api', options);
Winston
var winston = require('winston');
var proxyMiddleware = require("http-proxy-middleware");
var logProvider = function (provider) {
return {
log : winston.log,
debug : winston.debug,
info : winston.info,
warn : winston.warn,
error : winston.error
};
};
var options = {
target: 'http://localhost:3000',
logProvider: logProvider
};
var proxy = proxyMiddleware('/api', options);
Winston Multi Transport
var winston = require('winston');
var proxyMiddleware = require("http-proxy-middleware");
var logProvider = function (provider) {
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: 'somefile.log' })
]
});
return logger;
};
var options = {
target: 'http://localhost:3000',
logProvider: logProvider
};
var proxy = proxyMiddleware('/api', options);