You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dg...@apache.org on 2022/05/09 08:14:14 UTC

[unomi] branch fix-restclient-loglevel created (now 192a2d75d)

This is an automated email from the ASF dual-hosted git repository.

dgriffon pushed a change to branch fix-restclient-loglevel
in repository https://gitbox.apache.org/repos/asf/unomi.git


      at 192a2d75d UNOMI-567 : allow to set log level of rest client

This branch includes the following new commits:

     new 192a2d75d UNOMI-567 : allow to set log level of rest client

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: UNOMI-567 : allow to set log level of rest client

Posted by dg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dgriffon pushed a commit to branch fix-restclient-loglevel
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 192a2d75d11f9c297448ee7d9b3025ab2595ee30
Author: David Griffon <dg...@jahia.com>
AuthorDate: Mon May 9 10:13:59 2022 +0200

    UNOMI-567 : allow to set log level of rest client
---
 .../ElasticSearchPersistenceServiceImpl.java              | 15 ++++++++-------
 .../src/main/resources/OSGI-INF/blueprint/blueprint.xml   |  2 +-
 .../org.apache.unomi.persistence.elasticsearch.cfg        |  2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index 54adccbac..ad4c32cce 100644
--- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -240,7 +240,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
     private String itemClassesToCache;
     private boolean useBatchingForSave = false;
     private boolean useBatchingForUpdate = true;
-    private boolean errorLogLevelRestClient = true;
+    private String logLevelRestClient = "ERROR";
     private boolean alwaysOverwrite = true;
     private boolean aggQueryThrowOnMissingDocs = false;
     private Integer aggQueryMaxResponseSizeHttp = null;
@@ -435,17 +435,18 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
         this.alwaysOverwrite = alwaysOverwrite;
     }
 
-    public void setErrorLogLevelRestClient(boolean errorLogLevelRestClient) {
-        this.errorLogLevelRestClient = errorLogLevelRestClient;
+    public void setLogLevelRestClient(String logLevelRestClient) {
+        this.logLevelRestClient = logLevelRestClient;
     }
 
     public void start() throws Exception {
 
         // Work around to avoid ES Logs regarding the deprecated [ignore_throttled] parameter
-        if (errorLogLevelRestClient) {
-            org.apache.log4j.Logger.getLogger("org.elasticsearch.client.RestClient").setLevel(Level.ERROR);
-        } else {
-            org.apache.log4j.Logger.getLogger("org.elasticsearch.client.RestClient").setLevel(Level.INFO);
+        try {
+            Level lvl = Level.toLevel(logLevelRestClient, Level.ERROR);
+            org.apache.log4j.Logger.getLogger("org.elasticsearch.client.RestClient").setLevel(lvl);
+        } catch (Exception e) {
+            // Never fail because of the set of the logger
         }
 
         // on startup
diff --git a/persistence-elasticsearch/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/persistence-elasticsearch/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index fc44ae438..44e0411e6 100644
--- a/persistence-elasticsearch/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/persistence-elasticsearch/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -148,7 +148,7 @@
         <property name="sslTrustAllCertificates" value="${es.sslTrustAllCertificates}" />
         <property name="throwExceptions" value="${es.throwExceptions}" />
         <property name="alwaysOverwrite" value="${es.alwaysOverwrite}" />
-        <property name="errorLogLevelRestClient" value="${es.errorLogLevelRestClient}" />
+        <property name="logLevelRestClient" value="${es.logLevelRestClient}" />
     </bean>
 
     <!-- We use a listener here because using the list directly for listening to proxies coming from the same bundle didn't seem to work -->
diff --git a/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
index 75d84a470..b996c2a1c 100644
--- a/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
+++ b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
@@ -83,4 +83,4 @@ alwaysOverwrite=${org.apache.unomi.elasticsearch.alwaysOverwrite:-true}
 useBatchingForUpdate=${org.apache.unomi.elasticsearch.useBatchingForUpdate:-true}
 
 # ES logging
-errorLogLevelRestClient=${org.apache.unomi.elasticsearch.errorLogLevelRestClient:-true}
+logLevelRestClient=${org.apache.unomi.elasticsearch.logLevelRestClient:-ERROR}