配置log4js记录器以仅将INFO记录到控制台并将所有内容记录到文件

时间:2019-01-02 12:14:18

标签: node.js logging log4js-node

使用下面提到的log4js配置,我打算将所有内容记录到logs / test / log- timestamp .txt文件中的文件中,并且仅将INFO级别记录到控制台中,但是我看到了控制台将打印所有级别。我该如何解决?

{
    "appenders": {
        "test": {
            "type": "dateFile",
            "filename": "logs/test/log",
            "pattern": "-yyyy-MM-dd-hh-mm-ss.txt",
            "alwaysIncludePattern": true,
            "keepFileExt": true
        },
        "test-filter": {
            "type": "logLevelFilter",
            "appender": "test",
            "level": "trace",
            "maxLevel": "fatal"
        },
        "default": {
            "type": "dateFile",
            "filename": "logs/default",
            "pattern": "-yyyy-MM-dd.txt",
            "alwaysIncludePattern": true,
            "keepFileExt": true
        },
        "console": {
            "type": "console",
            "level": "info",
            "maxLevel": "info"
        }
    },
    "categories": {
        "default": {
            "appenders": [
                "default"
            ],
            "level": "info"
        },
        "test": {
            "appenders": [
                "test-filter",
                "console"
            ],
            "level": "debug"
        }
    }
}

0 个答案:

没有答案