Lesson 21 / 33
Logging
Built-in logger and integration with third-party loggers.
Built-in Logger
Inject Logger to log at different levels: debug, log, warn, error.
import { Logger, Injectable } from '@nestjs/common';
@Injectable()
export class UsersService {
private readonly logger = new Logger(UsersService.name);
create(user: User) {
this.logger.log(`Creating user: ${user.email}`);
return this.userRepository.save(user);
}
}Third-party loggers
Winston, Pino, or Bunyan—configure them in your main.ts or as a custom provider.