[QUESTION] How to use Pino for entire application with configuration options?
See original GitHub issueHi!
First of all, thanks for this module, it is really appreciated.
I am trying to use Pino Logger throughout the application; perhaps I am wrong about it, but what I am doing is to add the following code to app.module.ts
:
@Module({
imports: [
ConfigModule.forRoot(),
LoggerModule.forRoot({
pinoHttp: { prettyPrint: true, useLevelLabels: true }, // <--
}),
// ...
],
// ...
})
export class AppModule {}
And, in main.ts
:
import { NestFactory } from '@nestjs/core';
import { Logger } from 'nestjs-pino';
async function bootstrap() {
// Create the application.
const app = await NestFactory.create(AppModule, { logger: false });
// Get Pino Logger instance.
const logger = app.get(Logger);
// Use Pino as the main logger!
app.useLogger(logger);
// Start the server!
await app.listen(3030);
}
// Initialize application!
bootstrap();
The issue is that, if I import LoggerModule
and call forRoot
(or forRootAsync
by injecting ConfigService
etc), without any Pino options (prettyPrint
or useLevelLabels
) it works perfectly, however when adding even one option, it hangs the entire application without even booting!
- Is this the way to use the Logger throughout the Application?
- If it is, am I providing configuration options in a wrong format?
I would like to use Pino as the main logging system for the entire application, no exclusions.
I am using NestJS v7.
Again, thanks for this library! And thanks in advance for any commentary this might receive 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
A Complete Guide to Pino Logging in Node.js - Better Stack
In this tutorial, you will learn how to create a logging service for your application with Pino. We'll discuss many of the features...
Read more >How to Implement Logging in a Node.js Application With Pino ...
This tutorial is about implementing logging in a Node.js application using Pino-logger. With logging, you can store every bit of information ...
Read more >Logging with Pino and AsyncLocalStorage in Node.js
In this post, you can learn what a logging library is, why you should use it, and how to log with Pino and...
Read more >Create Industry-Standard Logger for Node.js Using Pino
A guide to creating an industry-standard logger for Node.js using Pino. ... This article is going to cover the use of the Pino...
Read more >How to avoid the entire request being logged every time using ...
The gist is to override the serializer for the request by including the following configuration option when initializing pino
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you very much @iamolegga ! Sorry to miss that part of the docs! Guess I just read this package ones and not the pino itself ones! Really sorry about this. Thanks for quick response and guidance 😃
Hey @humbertowoody just found the problem. When using
prettyPrint
property you need extra installation ofpino-pretty
as it said in docs 🙂