diff --git a/services/src/main/java/org/fao/geonet/api/site/LogUtils.java b/services/src/main/java/org/fao/geonet/api/site/LogUtils.java index 32a39a6990f..c9ac2a94741 100644 --- a/services/src/main/java/org/fao/geonet/api/site/LogUtils.java +++ b/services/src/main/java/org/fao/geonet/api/site/LogUtils.java @@ -29,7 +29,6 @@ import org.fao.geonet.exceptions.OperationAbortedEx; import org.fao.geonet.kernel.setting.Settings; import org.fao.geonet.repository.SettingRepository; -import org.springframework.beans.BeansException; import java.net.MalformedURLException; import java.net.URL; @@ -44,6 +43,7 @@ public class LogUtils { public static final String DEFAULT_LOG_FILE = "log4j.xml"; + public static final String GEONETWORK_LOG_CONFIGDIR_PROP = "geonetwork.log.configdir"; /** * Refresh logger configuration. If settings is not set in database, using default log4j.xml @@ -60,12 +60,7 @@ public static void refreshLogConfiguration() { } - String loggingConfigurationPath; - try { - loggingConfigurationPath = (String) ApplicationContextHolder.get().getBean("loggingConfigurationPath"); - } catch (BeansException e) { - loggingConfigurationPath = null; - } + String loggingConfigurationPath = System.getProperty(GEONETWORK_LOG_CONFIGDIR_PROP); // get log config from db settings String log4jProp = setting != null ? setting.getValue() : DEFAULT_LOG_FILE; URL url ; diff --git a/services/src/main/java/org/fao/geonet/api/site/LoggingApi.java b/services/src/main/java/org/fao/geonet/api/site/LoggingApi.java index 7b3a9a017af..632c45496ab 100644 --- a/services/src/main/java/org/fao/geonet/api/site/LoggingApi.java +++ b/services/src/main/java/org/fao/geonet/api/site/LoggingApi.java @@ -28,7 +28,6 @@ import org.apache.commons.io.IOUtils; import org.apache.log4j.FileAppender; import org.apache.log4j.Logger; -import org.fao.geonet.ApplicationContextHolder; import org.fao.geonet.api.site.model.ListLogFilesResponse; import org.fao.geonet.constants.Geonet; import org.fao.geonet.kernel.GeonetworkDataDirectory; @@ -92,13 +91,10 @@ public List getLogFiles( java.util.List logFileList = new ArrayList<>(); String loggingConfigurationFolder = dataDirectory.getWebappDir() + "/WEB-INF/classes"; - // overrides if a "loggingConfigurationPath" bean is available - try { - loggingConfigurationFolder = (String) ApplicationContextHolder.get().getBean("loggingConfigurationPath"); - } catch (Exception e) { - // stick with the folder in the classpath. + // overrides if a "geonetwork.log.configdir" is available as a java property + if (System.getProperty(LogUtils.GEONETWORK_LOG_CONFIGDIR_PROP) != null) { + loggingConfigurationFolder = System.getProperty(LogUtils.GEONETWORK_LOG_CONFIGDIR_PROP); } - File folder = new File(loggingConfigurationFolder); if (folder != null && folder.isDirectory()) {