#Impact of Logger

17 messages · Page 1 of 1 (latest)

tardy lava
#

If every component of nestjs has a logger instantiated and used for verbose, which can be disabled to output in production environment, what could be the impact on performance? or what are the best way to handle loggers in nestjs?

chilly lance
#

You might have some startup lag. Depending on how the verbose output is ignored there may be some degradation there

#

Though that will more depend on the check being made and how the log is passed, if it does any heavy computations, etc

tardy lava
#

Is there any build process where the logging can be removed from certain parts?

#

like pre-processors....

chilly lance
#

You could probably do it with webpack if you wanted

tardy lava
#

that nice... I will explore that..

#

Yes, webpack's Uglify plugin has option drop_console...

#

But it seems it will drop direct usage of console.log...

#

So if Logger from NestJs is used, it may not be useful.

#

in c#, there are code level directive to group certain code that can be for specific build targets only..

#
#if DEBUG
#endif

The above directive do not take the code within in other than DEBUG build target.

chilly lance
#

Yeah, I don't know if that exists in Typescript

restive aurora
#

Logging is the only way to debug your application in production, you absolutely want logs there

#

Usualy, you lower the log level to disable DEBUG level logs though

#

Logs does have impact on performance if they are printed synchronouly to the console in the main thread. If that's an issue, you can look at Pino logger, which uses worker threads to print messages in batches, which drastically increases the speed (it really does!). Not sure if Ogma has that feature? (Maybe it's something you could look into @chilly lance )

chilly lance