I want to use winston
logging module in my node application and I am using nest
framework.
So I installed
yarn add nest-winston
yarn add winston
and in my app.module.ts
WinstonModule.forRoot({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json(),
),
transports: [
new winston.transports.File({
dirname: process.env.LOG_FILE_PATH,
filename: 'info.log',
level: 'info',
}),
new winston.transports.File({
dirname: process.env.LOG_FILE_PATH,
filename: 'error.log',
level: 'error',
}),
],
}),
and in my contrller file i can inject like this
constructor(@Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly logger: LoggerService) { }
and this is working fine.
Now I have DB
class that is static
with static
methods. So there will be no constructor
. So how can I inject in this case.
And in my main.ts
there is no class so in that too how can i get the logger
instance.