Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-14142 Log in Solr's log whether request logging is enabled (#542)

Jan Høydahl1bc2e9b297e1
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 b915330427a..65ad8addf30 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 c3c749d2414..36ba3a791fe 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 d976ebf0d88..386f0b257a6 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>