Configure a logger to output information from http-proxy-middleware: ie. console
, winston
, pino
, bunyan
, log4js
, etc...
const { createProxyMiddleware } = require('http-proxy-middleware');
const proxy = createProxyMiddleware({
target: 'http://localhost:3000',
logger: console,
});
https://github.com/winstonjs/winston
const { createProxyMiddleware } = require('http-proxy-middleware');
const winston = require('winston');
const { format, transports } = require('winston');
// Enable interpolation in log messages
// https://github.com/winstonjs/winston#string-interpolation
const logger = winston.createLogger({
format: format.combine(format.splat(), format.simple()),
transports: [new transports.Console()],
});
const proxy = createProxyMiddleware({
target: 'http://localhost:3000',
logger,
});
https://github.com/pinojs/pino
const { createProxyMiddleware } = require('http-proxy-middleware');
const pino = require('pino');
const logger = pino();
const proxy = createProxyMiddleware({
target: 'http://localhost:3000',
logger,
});
https://github.com/log4js-node/log4js-node
const { createProxyMiddleware } = require('http-proxy-middleware');
const log4js = require('log4js');
const logger = log4js.getLogger();
logger.level = 'debug';
const proxy = createProxyMiddleware({
target: 'http://localhost:3000',
logger,
});
https://github.com/trentm/node-bunyan
const { createProxyMiddleware } = require('http-proxy-middleware');
const bunyan = require('bunyan');
const logger = bunyan.createLogger({
name: 'my-app',
});
const proxy = createProxyMiddleware({
target: 'http://localhost:3000',
logger,
});