Skip to content

Commit

Permalink
Merge pull request #1355 from ashitsalesforce/master
Browse files Browse the repository at this point in the history
initialize log4j configuration only once
  • Loading branch information
ashitsalesforce authored Oct 22, 2024
2 parents 880de39 + fe4659a commit e1c0959
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/salesforce/dataloader/util/LoggingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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()) {
Expand Down Expand Up @@ -113,8 +117,9 @@ public static synchronized void initializeLog(Map<String, String> 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) {
Expand Down

0 comments on commit e1c0959

Please sign in to comment.