Hi,
I would like Forest to use a custom winston logger in order for all my logs to be sent to the same log sink? Is there a configuration property to specify the logger we want Forest to use?
Thanks,
Matthieu.
Hi,
I would like Forest to use a custom winston logger in order for all my logs to be sent to the same log sink? Is there a configuration property to specify the logger we want Forest to use?
Thanks,
Matthieu.
Hi @matthieu,
Forest is using winston
in forest-express
, see here.
forest-express-sequelize
and forest-express-mongoose
are using forest-express
, but do not expose it. Additionnaly, the logger is statically created (== can’t be replaced).
If you want to provide Forest with your own winston
logger, a feature request will be needed, but please note we will not be able to provide an ETA for this.
A workaround would be to get then modify the Forest logger from your application:
const logger = require('forest-express').logger;
If all you need to change is updatable on an existing logger instance, then it’s ok.
Let me know if you would like to create the feature request.
Regards
Hi @Sliman_Medini,
Thank you for your answer.
In my case, I only needed to change the transports so updating the forest logger was enough:
import { logger as forestLogger } from 'forest-express';
// remove all transports set by Forest
forestLogger.transports.forEach((transport) =>
forestLogger.remove(transport),
);
// add all transports from your custom logger
logger.transports.forEach((transport) => forestLogger.add(transport));
It works well because I’m using winston. For other logging lib it would be harder so I think that it makes sense to create a feature request.