Skip to content

Commit 951e8de

Browse files
nizhikovtkledkov
authored andcommitted
IGNITE-17717 Fix APP_ID for Log4j2Logger (#10275)
(cherry picked from commit e6733ba)
1 parent 8785380 commit 951e8de

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public Log4J2Logger(final URL cfgUrl) throws IgniteCheckedException {
238238
*/
239239
static void cleanup() {
240240
synchronized (mux) {
241+
System.clearProperty(APP_ID);
242+
241243
if (inited)
242244
LogManager.shutdown();
243245

@@ -424,7 +426,9 @@ public static boolean isConfigured() {
424426

425427
// Set nodeId as system variable to be used at configuration.
426428
System.setProperty(NODE_ID, U.id8(nodeId));
427-
System.setProperty(APP_ID, application != null ? application : "ignite");
429+
System.setProperty(APP_ID, application != null
430+
? application
431+
: System.getProperty(APP_ID, "ignite"));
428432

429433
if (inited) {
430434
synchronized (mux) {

modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerSelfTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ public void testSystemNodeId() throws Exception {
146146

147147
assertEquals(U.id8(id), System.getProperty("nodeId"));
148148
assertEquals("other-app", System.getProperty("appId"));
149+
150+
new Log4J2Logger(LOG_PATH_TEST).setApplicationAndNode(null, id);
151+
152+
assertEquals(U.id8(id), System.getProperty("nodeId"));
153+
assertEquals("other-app", System.getProperty("appId"));
149154
}
150155

151156
/**

0 commit comments

Comments
 (0)