From 2193cf888193a3e583f29dec233e33cabf31f57f Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Mon, 15 Jan 2024 11:52:36 +0100 Subject: [PATCH] logging configuration file should be taken from georchestra datadir fixes #272 reinstated from 1ec55bea1, has been lost in fa284b7 --- .../org/fao/geonet/api/site/LogUtils.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 be4ac5197d..b54da7df23 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 @@ -79,9 +79,29 @@ public static void refreshLogConfiguration() { setting = settingOpt.get(); } + + String loggingConfigurationPath; + try { + loggingConfigurationPath = (String) ApplicationContextHolder.get().getBean("loggingConfigurationPath"); + CONFIG_LOG.info("Found loggingConfigurationPath='"+loggingConfigurationPath+"' in the bean configuration"); + } catch (BeansException e) { + loggingConfigurationPath = null; + } + // get log config from db settings String log4jProp = setting != null ? setting.getValue() : DEFAULT_LOG_FILE; - URL url = LogUtils.class.getResource("/" + log4jProp); + URL url ; + + if (loggingConfigurationPath != null) { + try { + url = Paths.get(loggingConfigurationPath, log4jProp).toUri().toURL(); + } catch (MalformedURLException e) { + url = LogUtils.class.getResource("/" + log4jProp); + } + } else { + url = LogUtils.class.getResource("/" + log4jProp); + } + try { if (url != null) { // refresh configuration