Skip to content

How to use Ogma logger with Nest Commander in main.ts? #884

Answered by jmcdo29
tukusejssirs asked this question in Q&A
Discussion options

You must be logged in to vote

Any logger that satisfies Nest's logger property is valid, however using ogma directly for that isn't always nice to have to instantiate the Ogma instance yourself, so instead with v3.7.0 you can do something like

async function bootstrap() {
  const app = await CommandFactory.createWithoutRunning(AppModule);
  app.useLogger(app.get(OgmaService)); // assuming `OgmaModule.forRoot()` has been imported
  await CommandFactory.runApplication(app);
}
bootstrap();

Docs on the createWithoutRunning

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@tukusejssirs
Comment options

@jmcdo29
Comment options

@tukusejssirs
Comment options

@jmcdo29
Comment options

@tukusejssirs
Comment options

Answer selected by tukusejssirs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants