无法在log4j2.json

时间:2019-07-23 08:23:53

标签: log4j2 rollingfileappender

我正在尝试使用JSON属性文件在Log4j2中配置两个滚动文件。使用我拥有的log4j2属性文件,我无法生成两个日志文件。

我尝试了以下方法: 1.将附加程序转换为数组,并为每个滚动文件配置提供两个对象作为附加程序。 (与此问题相同,附加了{JSON属性代码)

{
  "configuration": {
    "status": "trace",
    "name": "SeleniumLogging",
    "properties": {
      "property": {
        "name": "filename",
        "value": "src/test/resources/logs/rollingtest.log"
      }
    },
    "ThresholdFilter": {
      "level": "info"
    },
    "appenders": [
          {
            "type":"RollingFile",
            "name":"File",
            "fileName":"src/test/resources/selenium.log",
            "filePattern":"src/test/resources/selenium.log-%d{MM-dd-yy-HH-mm-ss}-%i.log",
            "PatternLayout": {
               "pattern":"%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%L - %m%n"
            },
            "Policies": {
               "OnStartupTriggeringPolicy": { 
               }
            },
            "DefaultRolloverStrategy": {
               "max":"3"
            }
         },
         {
            "type":"RollingFile",
            "name":"application",
            "fileName":"src/test/resources/application.log",
            "filePattern":"src/test/resources/application.log-%d{MM-dd-yy-HH-mm-ss}-%i.log",
            "PatternLayout": {
               "pattern":"%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%L - %m%n"
            },
            "Policies": {
               "OnStartupTriggeringPolicy": { 
               }
            },
            "DefaultRolloverStrategy": {
               "max":"3"
            }
         }
],
    "loggers": {
      "root": {
        "level": "info",
        "AppenderRef": {
          "ref": "File"
        }
         }, 
        "devpinoylogger": {
        "level": "info",
        "AppenderRef": {
          "ref": "application"
        }
      }
    }
  }
}

0 个答案:

没有答案