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/10 10:28:40 UTC
[unomi] branch unomi-1.6.x updated: UNOMI-567 : clean up logs - backport of #416 (#417)
This is an automated email from the ASF dual-hosted git repository.
dgriffon pushed a commit to branch unomi-1.6.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.6.x by this push:
new 96301e9b9 UNOMI-567 : clean up logs - backport of #416 (#417)
96301e9b9 is described below
commit 96301e9b9b567e262f3c17608cdfdf0a46321952
Author: David Griffon <dg...@jahia.com>
AuthorDate: Tue May 10 12:28:35 2022 +0200
UNOMI-567 : clean up logs - backport of #416 (#417)
* UNOMI-567 : clean up logs - backport of #416
* UNOMI-567 : allow to set log level of rest client
---
.../ElasticSearchPersistenceServiceImpl.java | 15 +++++++++++++--
.../src/main/resources/OSGI-INF/blueprint/blueprint.xml | 1 +
.../org.apache.unomi.persistence.elasticsearch.cfg | 3 +++
3 files changed, 17 insertions(+), 2 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 4ef4dcda7..d42beddf9 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
@@ -27,6 +27,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.log4j.Level;
import org.apache.lucene.search.TotalHits;
import org.apache.unomi.api.Item;
import org.apache.unomi.api.PartialList;
@@ -120,7 +121,6 @@ import javax.net.ssl.X509TrustManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.lang.reflect.Field;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@@ -130,7 +130,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@@ -202,6 +201,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
private String itemClassesToCache;
private boolean useBatchingForSave = false;
private boolean useBatchingForUpdate = true;
+ private String logLevelRestClient = "ERROR";
private boolean alwaysOverwrite = true;
private boolean aggQueryThrowOnMissingDocs = false;
private Integer aggQueryMaxResponseSizeHttp = null;
@@ -396,9 +396,20 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
this.alwaysOverwrite = alwaysOverwrite;
}
+ 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
+ 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
new InClassLoaderExecute<Object>(null, null, this.bundleContext, this.fatalIllegalStateErrors, throwExceptions) {
public Object execute(Object... args) throws Exception {
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 f628a8c23..31259468e 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
@@ -146,6 +146,7 @@
<property name="sslTrustAllCertificates" value="${es.sslTrustAllCertificates}" />
<property name="throwExceptions" value="${es.throwExceptions}" />
<property name="alwaysOverwrite" value="${es.alwaysOverwrite}" />
+ <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 71c2577b7..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
@@ -81,3 +81,6 @@ throwExceptions=${org.apache.unomi.elasticsearch.throwExceptions:-false}
alwaysOverwrite=${org.apache.unomi.elasticsearch.alwaysOverwrite:-true}
useBatchingForUpdate=${org.apache.unomi.elasticsearch.useBatchingForUpdate:-true}
+
+# ES logging
+logLevelRestClient=${org.apache.unomi.elasticsearch.logLevelRestClient:-ERROR}