log4js中的自定义级别

问题描述

我正在尝试为log4js添加自定义级别。但是,我在下面看到一个错误

No overload matches this call.
Overload 1 of 2,'(filename: string): Log4js',gave the following error.
Argument of type '{ levels: { NOTICE: { value: number; colour: string; }; }; appenders: { 
out: { type: string; layout: { type: string; separator: string; }; }; aws: { type: string; 
layout: { type: string; separator: string; }; }; log: { ...; }; }; categories: { ...; }; }' 
is not assignable to parameter of type 'string'.
Overload 2 of 2,'(config: Configuration): Log4js',gave the following error.
Type '{ NOTICE: { value: number; colour: string; }; }' is not assignable to type 'Levels'.
Object literal may only specify kNown properties,and 'NOTICE' does not exist in type 
'Levels'.ts(2769)
log4js.d.ts(282,2): The expected type comes from property 'levels' which is declared here 
on type 'Configuration'

以下是我的配置:

configure({
  levels: {
    NOTICE: { value: 20001,colour: 'green' }
  },appenders: {
    out: { type: 'stdout',layout: { type: 'customLayout',separator: ' | ' } }
  },categories: {
    default: { appenders: ['out'],level: 'info' }
  }
});

我不确定我在哪里出错了,就像我按照文档所述那样实现了代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)