Closed amctavish closed 4 years ago
It looks like you are using Logger.debug()
which is the static method instead of the instance method which would require you to instantiate the logger first and then call the expected method. You could do something like this:
const myLoggeer = new LoggerService();
myLogger.debug('my message');
And you should get the desired results.
Hmm, I would have expected this to have set the static property Logger.instance
and then calling Logger.debug
to have called debug
on the singleton instance I've set.
Having had a better look at the code I now see that Logger.printMessage
doesn't actually touch the instance property. It looks like I've made an incorrect assumption.
Thanks for the respose.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Bug Report
Current behavior
When passing your own logger implementation via
options.logger
toNestFactory.create
, callingapp.useLogger
on the resulting NestApplication instance or evenLogger.overrideLogger
it should replace the Logger singleton instance in@nestjs/common
but it appears to still be using the default instance.I thought it might have been juse because I'm extending
Logger
but the same is true when implementing theLoggerService
interface.Input Code
https://codesandbox.io/s/nest-typescript-starter-1izwc
Expected behavior
When either passing a custom logger implementation via
options.logger
toNestFactory.create
,app.useLogger
to the resulting NestApplication orLogger.overrideLogger
theLogger
singleton in@nestjs/common
should use the custom logger instance instead of Nests default logger instance.Environment
Nest version: 6.9.0