Hi I am using Apollo Federation and am trying to use fine grained logging as specified by the Apollo docs however I am unable to see any logs from the willSendResponse
, and didEncounterErrors
lifecycle events.
apollo-server version: “^3.5.0”
apollo-gateway version: “^0.44.1”
logging library: bunyan
This is the plugin I created:
const basicLogging = {
async requestDidStart(requestContext) {
logger.info('Request Started', requestContext.request);
const start = performance.now()
let operation;
return {
async didResolveOperation(context) {
operation = context.operationName;
},
async willSendResponse(responseContext) {
const elapsed = Math.round(performance.now() - start);
const size = Buffer.from(JSON.stringify(responseContext.response)).length;
logger.info('Response Ready', {
operation: operation,
duration: `${elapsed} ms`,
size: `${size} bytes`,
response: responseContext.response
});
},
async didEncounterErrors(requestContext) {
logger.error('Errors Encountered', {
operation: operation,
request: requestContext.request,
errors: requestContext.errors
});
}
};
}
};
I am able to see the log ‘Request Started’ but nothing else from the other lifecycle events. Is there something I am missing?