Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] @nestjs/platform-fastify support Custom Log Level #14137

Open
1 task done
daimalou opened this issue Nov 13, 2024 · 3 comments
Open
1 task done

[Feature Request] @nestjs/platform-fastify support Custom Log Level #14137

daimalou opened this issue Nov 13, 2024 · 3 comments
Labels
needs triage This issue has not been looked into type: enhancement 🐺

Comments

@daimalou
Copy link

daimalou commented Nov 13, 2024

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I use fastify buildin logger, this logger is awesome, has builtin traceId feature and can access by request.log.info()

https://fastify.dev/docs/v4.28.x/Reference/Logging/

It works.

  const fastifyInstance = fastify({
    logger: true,
  });

  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter(fastifyInstance),
    {
      logger: false,
    },
  );

But this logger log every request and response. I find a solution to close some route. But In Nest I can't find place to config.

solution:
fastify/fastify#2120
fastify/help#140
https://fastify.dev/docs/latest/Reference/Routes/#custom-log-level

Describe the solution you'd like

Give a config.

Teachability, documentation, adoption, migration strategy

None

What is the motivation / use case for changing the behavior?

None

@daimalou daimalou added needs triage This issue has not been looked into type: enhancement 🐺 labels Nov 13, 2024
@Tony133
Copy link
Contributor

Tony133 commented Nov 18, 2024

If I understand you correctly, you want to know how to use request.log.info(), with @nestjs/platform-fastify package ?

@daimalou
Copy link
Author

@Tony133, I need a configuration in nest to close some route log.

like this fastify.register(require('./routes/your-route'), { logLevel: 'silent' })

@daimalou
Copy link
Author

daimalou commented Nov 19, 2024

I found the key code. I'll try modifying it.
https://github.com/nestjs/nest/tree/master/packages/platform-fastify/decorators
https://github.com/nestjs/nest/blob/master/packages/platform-fastify/adapters/fastify-adapter.ts#L726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: enhancement 🐺
Projects
None yet
Development

No branches or pull requests

2 participants