Closed mh377 closed 1 year ago
I am able to append a custom header: x-request-id to each log message for REST requests but not for GraphQL requests.
x-request-id
I should be able to append a custom header x-request-id to each log message for BOTH REST and GraphQL requests.
Instructions are in the README.md of the following repo:
https://github.com/mh377/nestjs-graphql-sample
Logger Configuration:
@Module({ imports: [ PinoLoggerModule.forRootAsync({ imports: [ConfigModule.forRoot({ isGlobal: true })], useFactory: async (configService: ConfigService) => ({ isGlobal: true, pinoHttp: { level: 'trace', redact: configService.get<string[]>('logger.redact.fields'), transport: { target: 'pino-pretty', options: { colorize: false, singleLine: true, levelFirst: false, translateTime: "yyyy-mm-dd'T'HH:MM:ss.l'Z'", messageFormat: '{req.headers.x-request-id} [{context}] {msg}', ignore: 'pid,hostname,context,req,res.headers', errorLikeObjectKeys: ['err', 'error'], }, }, }, }), inject: [ConfigService], }), ], controllers: [], providers: [], }) export class LoggerModule {}
Thanks for reporting. We do not have the resources to support Nest.js users. Please refer to the Nest Discord channel (support) for such questions.
What is the current behavior?
I am able to append a custom header:
x-request-id
to each log message for REST requests but not for GraphQL requests.What is the expected behavior?
I should be able to append a custom header
x-request-id
to each log message for BOTH REST and GraphQL requests.Sample Code Repo
Instructions are in the README.md of the following repo:
https://github.com/mh377/nestjs-graphql-sample
Additional Information
Logger Configuration: