New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add new appenders dynamically. #1415
Comments
If you maintain a copy of your configuration, you can modify it and reload log4js by var log4js = require('log4js');
var logger = log4js.getLogger();
// load config
var config = {
appenders: {
out1: { type: 'stdout' },
},
categories: {
default: {
appenders: [ 'out1' ],
level: 'all'
}
}
};
log4js.configure(config);
logger.info("hello should appear once");
// adding new appenders
config.appenders.out2 = { type: 'stdout' };
config.categories.default.appenders.push('out2');
// reload config
log4js.configure(config);
logger.info("hello should appear twice"); |
Thanks @lamweili infact I have done same way. maintain copy of configurations and reload everytime when dynamically required. |
Please close the issue if it has been resolved. Thanks! |
Programatically how can we add new appenders to log to new file. I want to make general function where i can create new logger with proper names and write to its own file.
But log4js seems to be called only once.
I wrote a general code,
Using this class providing log name, and file path, i wanted to create multiple log instances and log to sep files dynamically. Different files may have different log methods.
But this does not seem working as some times it does not get logged. I do not know why ?
The text was updated successfully, but these errors were encountered: