I am using "log4js": "^4.3.1"
. I am having a main file that configures the class and the logger
instance.
const {
StartLogger
} = require('./StartLogger')
const log4js = require('log4js');
log4js.configure('./config/log4js-config.json');
async function main() {
const logger = log4js.getLogger();
logger.level = 'info';
const startLogger = new StartLogger(logger)
startLogger.hello("hello")
}
main()
My class looks like the following:
const log4js = require('log4js');
class StartLogger {
constructor(log) {
logger = log
}
hello(msg) {
this.logger.info("Your Message: " + msg);
}
}
module.exports = {
StartLogger
};
However, I get - rightfully - the following exception:
ReferenceError: logger is not defined
Any suggestion how to pass the configured instance to the class?
I appreciate your replies!