Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When set LoggerService as the main logger, it throws errors upon initialization #174

Closed
hieumdd opened this issue Mar 9, 2023 · 1 comment

Comments

@hieumdd
Copy link

hieumdd commented Mar 9, 2023

Excellent package btw, that is just what I'm looking for :D

I've set up a module for logging like this

import { Module } from '@nestjs/common';
import { LoggerModule as GCLoggerModule } from 'gc-json-logger-nestjs';

@Module({
    imports: [
        GCLoggerModule.register({
            routes: ['*'],
            global: true,
        }),
    ],
})
export class LoggerModule {}

and import it into the main AppModule and use it as the main app logger as follows

import { LoggerService } from 'gc-json-logger-nestjs';

app.useLogger(app.get(LoggerService));

I got this error
image

So I think this has to do with severity being wrongly applied.
After digging up the debug panels I find this

  1. The default nestjs logger use log(message, ...)
    image
  2. our GCNestJS logger use log(severity, message, ...) as the signature
    image

This leads to message being wrongly applied to severity. This could also be that I'm doing it correctly, if so can you help me out on what is the correct approach to use this as the default app logger?

Many thanks for this package (and the core package as well)

@hieumdd
Copy link
Author

hieumdd commented Mar 9, 2023

I found that using AdapterLoggerService instead of LoggerService did the job

@hieumdd hieumdd closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant