#Logger in functional component

21 messages · Page 1 of 1 (latest)

slow anvil
#

Hello,

I've a Custom Middleware in Nestjs which I've written in Functional Middleware, but unfortunately I am not able to use Logger & don't have any idea that how to use Logger in that from @nestjs/common .

can anyone help me how to use Logger from @nestjs/common in Functional Middleware?

limpid monolith
#

i think you can achieve that with a class based middleware

slow anvil
limpid monolith
#

so why you need a logger there?

limpid monolith
slow anvil
limpid monolith
slow anvil
limpid monolith
#

i think that should be at the controller isnt?

#

if i were you i would do it at the controller so i do the validation at the controller in the specific route i need it for

slow anvil
limpid monolith
#

can you show me the code of how you are doing it

slow anvil
outer adder
#

But, if you use Nest's logger abstraction, you don't need to use DI, you can just call new Logger(name) and use that. The loogger is gobal and proxies call to any custom logger configured with app.useLogger

outer adder
limpid monolith
#

if so maybe this would be more clear for him