4
這是我log4j2 JSON配置主要錯誤無法找到的appender「測試」記錄器配置「測試」
{
"Configuration": {
"Appenders": {
"Console": {
"PatternLayout": {
"pattern": "%d{yyyy-MMM-dd HH:mm:ss a} [%t] %-5level %logger{36} - %msg%n"
},
"name": "Console",
"target": "SYSTEM_OUT"
},
"RollingFile": {
"name": "general",
"fileName": "C:/logs/simulator-log.log",
"filePattern": "C:/logs/simulator-log-%d{yyyy-MM-dd HH-mm-ss}.log",
"PatternLayout": {
"pattern": "%msg%n"
},
"Policies": {
"OnStartupTriggeringPolicy": {
}
}
},
"File": {
"PatternLayout": {
"pattern":"%msg%n"
},
"name": "test",
"fileName": "c:/logs/requests_received.log"
},
"File": {
"PatternLayout": {
"pattern":"%msg%n"
},
"name": "test1",
"fileName": "c:/logs/response_sent.log"
}
},
"Loggers": {
"Root": {
"AppenderRef": [
{
"ref": "Console"
}
],
"level": "trace"
},
"logger": [
{
"name": "test",
"level": "trace",
"additivity":"false",
"AppenderRef": {
"ref": "test"
}
},
{
"name": "test1",
"level": "trace",
"additivity":"false",
"AppenderRef": {
"ref": "test1"
}
},
{
"name": "general",
"level": "trace",
"additivity":"false",
"AppenderRef": {
"ref": "general"
}
}
]
}
}
}
當我使用一個文件追加程序正常工作。當我使用兩個文件appender在title.cant中提到錯誤時,我們添加了多個文件appender。我不想使用滾動文件appender。
請忽略此內容「看起來你的文章主要是代碼,請添加一些更多的細節,你想要什麼更多的細節?我想我已經傳達了一切,還有什麼你想讓我補充的。問題。」創建記錄變量
private static final Logger requestsReceived = LogManager.getLogger("test");
private static final Logger responseSent = LogManager.getLogger("test1");
private static final Logger logger = LogManager.getLogger("general");
它的工作原理。非常感謝您提供完整的json配置。 – hmmm