From fe4659a5b9c2646195d0db4b880b9ed2576f6b18 Mon Sep 17 00:00:00 2001 From: ashitsalesforce Date: Tue, 22 Oct 2024 08:45:35 -0700 Subject: [PATCH] initialize log4j configuration only once initialize log4j configuration only once --- .../java/com/salesforce/dataloader/util/LoggingUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/salesforce/dataloader/util/LoggingUtil.java b/src/main/java/com/salesforce/dataloader/util/LoggingUtil.java index d4ed477c..23cd3a63 100644 --- a/src/main/java/com/salesforce/dataloader/util/LoggingUtil.java +++ b/src/main/java/com/salesforce/dataloader/util/LoggingUtil.java @@ -56,9 +56,13 @@ public class LoggingUtil { private static final String LOG_CONF_DEFAULT_PROPERTIES = "log4j2.properties"; public static String LOG_CONF_DEFAULT = LOG_CONF_DEFAULT_PROPERTIES; private static Logger logger; + private static boolean logInitialized = false; public static synchronized void initializeLog(Map argsMap) throws FactoryConfigurationError, IOException { + if (logInitialized) { + return; + } // check the environment variable for log4j String log4jConfigFilePath = System.getenv("LOG4J_CONFIGURATION_FILE"); if (log4jConfigFilePath == null || log4jConfigFilePath.isEmpty()) { @@ -113,8 +117,9 @@ public static synchronized void initializeLog(Map argsMap) throw // this will force a reconfiguration context.setConfigLocation(file.toURI()); - logger = LogManager.getLogger(AppUtil.class); - logger.debug(Messages.getMessage(AppUtil.class, "logInit")); //$NON-NLS-1$ + logger = LogManager.getLogger(LoggingUtil.class); + logger.debug(Messages.getMessage(LoggingUtil.class, "logInit")); //$NON-NLS-1$ + logInitialized = true; } public static void setLoggingLevel(String newLevelStr) {