我有以下旧的log4js代码,我需要转换为新的log4js格式,但我很困惑如何做到这一点,有人可以请帮助
log4js.configure({
appenders:[
{
"type": "console",
"category": "debug_console"
},
{
"type": "file",
"absolute": true,
"filename": path.dirname(require.main.filename) + "/"+config.logs.debug_file,
"category": "debug",
"additivity": false
},
{
"type": "console",
"category": "error_console"
},
{
"type": "file",
"absolute": true,
"filename": path.dirname(require.main.filename) + "/"+config.logs.error_file,
"category": "error_file",
"additivity": false
}
],
replaceConsole: false
});
var debug_console = log4js.getLogger('debug_console');
var debug_file = log4js.getLogger('debug');
var error_console = log4js.getLogger('error_console');
var error_file = log4js.getLogger('error_file');
答案 0 :(得分:0)
我不知道这是否正确我能够在下面对此进行排序,可能会对某人有所帮助,
log4js.configure({
appenders: { debug_console: { type: 'console'} },
categories: { default: { appenders: ['debug_console'], level: 'trace' } },
replaceConsole: true
});
log4js.configure({
appenders: { debug: { type: 'file', filename: path.dirname(require.main.filename) + "/"+config.logs.debug_file } },
categories: { default: { appenders: ['debug'], level: 'debug' } },
replaceConsole: false
});
log4js.configure({
appenders: { error_console: { type: 'console'} },
categories: { default: { appenders: ['error_console'], level: 'error' } },
replaceConsole: true
});
log4js.configure({
appenders: { error_file: { type: 'file', filename: path.dirname(require.main.filename) + "/"+config.logs.error_file } },
categories: { default: { appenders: ['error_file'], level: 'error' } },
replaceConsole: false
});