【问题标题】:Error with log4js configuration: must have a property "appenders" of type objectlog4js 配置错误:必须有一个对象类型的属性“appenders”
【发布时间】:2017-12-22 13:02:43
【问题描述】:

我收到错误:log4js 配置有问题:({ appenders: [ {类型:'logLevelFilter', 级别:'信息', appenders: { type: 'console' } } ] }) - 必须有一个 object 类型的属性“appenders”。

我的 protractor.conf.js 文件 sn-p:

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

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

【问题讨论】:

    标签: protractor log4js-node


    【解决方案1】:

    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

    【讨论】:

      【解决方案2】:

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

      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】:

        在 2.x 版本中更改了配置格式

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

        【讨论】:

          猜你喜欢
          • 2010-11-23
          • 1970-01-01
          • 2018-07-09
          • 2013-10-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多