1

我收到错误:log4js 配置问题:({ appenders: [ { type: 'logLevelFilter', level: 'INFO', appenders: { type: 'console' } } ] }) - 必须有一个属性“appenders”类型对象。

我的 protractor.conf.js 文件片段:

beforeLaunch:function(){
    log4js.configure({
        appenders: 
        [{ type: 'log4js-protractor-appender', 
category: 'protractorLog4js' },
            {
                type: "file",
                filename: './logs/ExecutionLog.log',
                category: 'protractorLog4js'
            }
        ]
    });
  },

我不确定为什么我会收到此错误,即使 conf 中有附加程序。

4

3 回答 3

4

在新版本中,您的附加程序将如下所示:

appenders: {
fileLog: { type: 'file', filename: './logs/ExecutionLog.log' },
console: { type: 'log4js-protractor-appender' }
},
categories: {
file: { appenders: ['fileLog'], level: 'error' },
another: { appenders: ['console'], level: 'trace' },
default: { appenders: ['console', 'fileLog'], level: 'trace' }
}
于 2017-09-08T21:24:43.107 回答
4

1.x 版中的 log4js-node 使用您的格式:

appenders:[] // Array

但是 2.x 版本中的对象是这样的:

appenders: {
    cheeseLogs: { type: 'file', filename: 'cheese.log' },
    console: { type: 'console' }
  },
 categories: {
    cheese: { appenders: ['cheeseLogs'], level: 'error' },
    another: { appenders: ['console'], level: 'trace' },
    default: { appenders: ['console', 'cheeseLogs'], level: 'trace' }
}

https://github.com/nomiddlename/log4js-node

于 2017-07-24T08:18:38.087 回答
1

2.x 版更改了配置格式

https://github.com/nomiddlename/log4js-node/issues/500

于 2017-07-18T13:00:42.227 回答