我正在尝试使用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"
}
}
}
}
}