You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ja...@apache.org on 2022/01/21 17:11:57 UTC

[solr] branch branch_9_0 updated: SOLR-14142 Log in Solr's log whether request logging is enabled (#542)

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

janhoy pushed a commit to branch branch_9_0
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9_0 by this push:
     new 5215a13  SOLR-14142 Log in Solr's log whether request logging is enabled (#542)
5215a13 is described below

commit 5215a1331a6bcb8969dbc5a2d791778b5d1f0be5
Author: Jan Høydahl <ja...@users.noreply.github.com>
AuthorDate: Fri Jan 21 17:51:44 2022 +0100

    SOLR-14142 Log in Solr's log whether request logging is enabled (#542)
    
    Co-authored-by: Mike Drob <md...@apache.org>
    (cherry picked from commit 1bc2e9b297e161c017f9f060dc1b7fbd27fdabdb)
---
 .../src/java/org/apache/solr/core/CoreContainer.java     |  3 +++
 .../java/org/apache/solr/util/StartupLoggingUtils.java   | 16 ++++++++++++++++
 solr/server/etc/jetty-requestlog.xml                     |  2 ++
 3 files changed, 21 insertions(+)

diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index b915330..65ad8ad 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -110,6 +110,7 @@ import org.apache.solr.update.SolrCoreState;
 import org.apache.solr.update.UpdateShardHandler;
 import org.apache.solr.util.OrderedExecutor;
 import org.apache.solr.util.RefCounted;
+import org.apache.solr.util.StartupLoggingUtils;
 import org.apache.solr.util.stats.MetricUtils;
 import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
@@ -730,6 +731,8 @@ public class CoreContainer {
 
     logging = LogWatcher.newRegisteredLogWatcher(cfg.getLogWatcherConfig(), loader);
 
+    StartupLoggingUtils.checkRequestLogging();
+
     hostName = cfg.getNodeName();
 
     zkSys.initZooKeeper(this, cfg.getCloudConfig());
diff --git a/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java b/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
index c3c749d..36ba3a7 100644
--- a/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
@@ -187,4 +187,20 @@ public final class StartupLoggingUtils {
     else if (rootLogger.isErrorEnabled()) return "ERROR";
     else return "INFO";
   }
+
+  /**
+   * Check whether Jetty request logging is enabled and log info about it.
+   * The property "solr.log.requestlog.enabled is set in solr/server/etc/jetty-requestlog.xml
+   */
+  public static void checkRequestLogging() {
+    boolean requestLogEnabled = Boolean.getBoolean("solr.log.requestlog.enabled");
+    String retainDays= System.getProperty("solr.log.requestlog.retaindays");
+    if (requestLogEnabled) {
+      if (retainDays == null) {
+        log.warn("Jetty request logging enabled. Will retain logs for last 3 days. See chapter \"Configuring Logging\" in reference guide for how to configure.");
+      } else {
+        log.info("Jetty request logging enabled. Will retain logs for last {} days.", retainDays);
+      }
+    }
+  }
 }
diff --git a/solr/server/etc/jetty-requestlog.xml b/solr/server/etc/jetty-requestlog.xml
index d976ebf..386f0b2 100644
--- a/solr/server/etc/jetty-requestlog.xml
+++ b/solr/server/etc/jetty-requestlog.xml
@@ -40,4 +40,6 @@
       <Arg><Get class="org.eclipse.jetty.server.CustomRequestLog" name="NCSA_FORMAT"/></Arg>
     </New>
   </Set>
+  <!-- System property used to detect inside of Solr whether the requestlog is enabled, for logging purposes -->
+  <Call class="java.lang.System" name="setProperty"><Arg>solr.log.requestlog.enabled</Arg><Arg>true</Arg></Call>
 </Configure>