Categories
JavaScript Answers

How to use Node Nest.js Logging service?

Spread the love

To use Node Nest.js Logging service, we use the Logger constructor.

For instance, we write

@Controller()
export class AppController {
  private readonly logger = new Logger(AppController.name);

  @Get()
  async get() {
    this.logger.log("Getting stuff");
  }
}

to create a Logger object with the name of the controller.

Then we call logger.log to log some text.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *