I would like to log every single request that express gateway receives, but it seems I can't decide what to log .
I tried to integrate morgan('immediate')
From https://github.com/expressjs/morgan
/* Create a sub app */
const subApp = express();
subApp.use(registration({ container }));
subApp.use(guestRequest({ container }));
subApp.use(statistics({ container }));
subApp.use(deleteUser({ container }));
subApp.use(relationRequest({ container }));
subApp.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
subApp.use(morgan('immediate'))
subApp.use(cors({ origin: true, credentials: true }));
subApp.set('view engine', 'ejs');
subApp.set('views', viewsPath);
but it looks like its not being used.
Anyone successfully integrated advanced logging in express gateway ?
I also tried Longjohn and same issue.
You can do this using Express Gateway out-of-the box.
First, define an apiEndpoint for all requests:
apiEndpoints:
all:
host: "*"
paths: "*"
Then, set up a pipeline which logs all requests hitting this apiEndpoint:
policies:
log
pipelines:
logRequest:
apiEndpoints:
- all
policies:
- log
- action:
message: "{req.method} {req.originalUrl} ${JSON.stringify(req.headers)}"
If you need to log more, consider enabling Express Gateway and/or Express diagnostic logging using the environment variables:
LOG_LEVEL=debug
(for Express Gateway)DEBUG=express:*
(for Express.js)