Error with log4js configuration: must have a property “appenders” of type object

让人想犯罪 __ 提交于 2019-12-11 04:59:23

问题


I am getting Error: Problem with log4js configuration: ({ appenders: [ { type: 'logLevelFilter', level: 'INFO', appenders: { type: 'console' } } ] }) - must have a property "appenders" of type object.

My protractor.conf.js file snippet:

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

I am not sure why i am getting this error even though there is appenders in the conf.


回答1:


log4js-node in version 1.x using format like yours:

appenders:[] // Array

but Object in version 2.x like this:

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




回答2:


In the new version your appenders would look like this:

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' }
}



回答3:


Configuration format changed in version 2.x

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



来源:https://stackoverflow.com/questions/45153599/error-with-log4js-configuration-must-have-a-property-appenders-of-type-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!