Giter Club home page Giter Club logo

Comments (8)

bezenson avatar bezenson commented on September 25, 2024 1

@TroyMorvant No, winston is used. All steps are taken from readme.

I think secret is here:

  const app = await NestFactory.create(AppModule, {
    logger: WinstonModule.createLogger({
      // options (same as WinstonModule.forRoot() options)
    })

And then import from @nestjs/common should be used

from nest-winston.

TroyMorvant avatar TroyMorvant commented on September 25, 2024

Description

I've picked "Replacing the Nest logger (also for bootstrapping)" to setup logger.

In the end of section there are 2 requirements:

  1. Add Logger to AppModule providers.
  2. Inject in class constructor:
import { Controller, Logger } from '@nestjs/common';

@Controller('cats')
export class CatsController {
  constructor(private readonly logger: Logger) {}
}

But as a result I am getting next error:

Error: Nest can't resolve dependencies of the CatsController

After some investigation I found another way to use logger in class in official documentation here.

import { Logger, Injectable } from '@nestjs/common';

@Injectable()
class MyService {
  private readonly logger = new Logger(MyService.name);

  doSomething() {
    this.logger.log('Doing something...');
  }
}

And now everything is works. No need to add into providers list. So yeah.. Is it ok? Should documentation be updated?

Wouldn't this just be using the built in nest logger and not the custom logger?

from nest-winston.

a1rwulf avatar a1rwulf commented on September 25, 2024

Same here.

private readonly logger = new Logger(MyService.name);

Seems to work instead of trying to put it in the constructor.

from nest-winston.

bingyang519 avatar bingyang519 commented on September 25, 2024

Solve it in another way

app.module.ts

@global() // important
@module({
providers: [Logger],
exports: [Logger], // important
})
export class AppModule {}

from nest-winston.

github-actions avatar github-actions commented on September 25, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

from nest-winston.

github-actions avatar github-actions commented on September 25, 2024

This issue was closed because it has been stalled for 7 days with no activity.

from nest-winston.

drewB avatar drewB commented on September 25, 2024

I definitely think the documentation should be updated. Since most people will be migrating from the default nest way of using the logger which is exactly the same the @inferusvv solution it is much less effort.

from nest-winston.

tapqr avatar tapqr commented on September 25, 2024

waste a week to solve this problem

from nest-winston.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.