You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2019/12/21 22:59:54 UTC

[lucene-solr] 01/01: SOLR-14138: enable request log via environ var

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

rmuir pushed a commit to branch jira/SOLR-14138
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit b2db7a282b1bf0f9e3c1a8ad5440d98032d8111f
Author: Robert Muir <rm...@apache.org>
AuthorDate: Sat Dec 21 17:59:33 2019 -0500

    SOLR-14138: enable request log via environ var
---
 solr/bin/solr                        |  5 ++++
 solr/bin/solr.cmd                    |  5 ++++
 solr/bin/solr.in.cmd                 |  3 +++
 solr/bin/solr.in.sh                  |  3 +++
 solr/server/etc/jetty-requestlog.xml | 51 ++++++++++++++++++++++++++++++++++++
 solr/server/etc/jetty.xml            | 27 -------------------
 solr/server/modules/requestlog.mod   |  9 +++++++
 7 files changed, 76 insertions(+), 27 deletions(-)

diff --git a/solr/bin/solr b/solr/bin/solr
index 8a3a3ac..8cdd114 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -262,6 +262,11 @@ else
   SOLR_JETTY_CONFIG+=("--module=http")
 fi
 
+# Requestlog options
+if [ "$SOLR_REQUESTLOG_ENABLED" == "true" ]; then
+  SOLR_JETTY_CONFIG+=("--module=requestlog")
+fi
+
 # Authentication options
 if [ -z "$SOLR_AUTH_TYPE" ] && [ -n "$SOLR_AUTHENTICATION_OPTS" ]; then
   echo "WARNING: SOLR_AUTHENTICATION_OPTS environment variable configured without associated SOLR_AUTH_TYPE variable"
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 974d7e1..c94f3c1 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -125,6 +125,11 @@ IF "%SOLR_SSL_ENABLED%"=="true" (
   set SOLR_SSL_OPTS=
 )
 
+REM Requestlog options
+IF "%SOLR_REQUESTLOG_ENABLED%"=="true" (
+  set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=requestlog"
+)
+
 REM Authentication options
 
 IF NOT DEFINED SOLR_AUTH_TYPE (
diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmd
index e462336..c6cc5b9 100755
--- a/solr/bin/solr.in.cmd
+++ b/solr/bin/solr.in.cmd
@@ -102,6 +102,9 @@ REM start rotation of logs. This is false by default as log4j2 handles this for
 REM framework that cannot do startup rotation, you may want to enable this to let Solr rotate logs on startup.
 REM set SOLR_LOG_PRESTART_ROTATION=false
 
+REM Enables jetty request log for all requests
+REM set SOLR_REQUESTLOG_ENABLED=false
+
 REM Set the host interface to listen on. Jetty will listen on all interfaces (0.0.0.0) by default.
 REM This must be an IPv4 ("a.b.c.d") or bracketed IPv6 ("[x::y]") address, not a hostname!
 REM set SOLR_JETTY_HOST=0.0.0.0
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index d4e6b7b..c47afc4 100644
--- a/solr/bin/solr.in.sh
+++ b/solr/bin/solr.in.sh
@@ -123,6 +123,9 @@
 # framework that cannot do startup rotation, you may want to enable this to let Solr rotate logs on startup.
 #SOLR_LOG_PRESTART_ROTATION=false
 
+# Enables jetty request log for all requests
+#SOLR_REQUESTLOG_ENABLED=false
+
 # Sets the port Solr binds to, default is 8983
 #SOLR_PORT=8983
 
diff --git a/solr/server/etc/jetty-requestlog.xml b/solr/server/etc/jetty-requestlog.xml
new file mode 100644
index 0000000..1ed51a6
--- /dev/null
+++ b/solr/server/etc/jetty-requestlog.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
+
+<!-- =========================================================== -->
+<!-- Configure Request Log                                       -->
+<!-- =========================================================== -->
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+  <!-- =========================================================== -->
+  <!-- Configure Request Log                                       -->
+  <!-- =========================================================== -->
+  <Ref id="Handlers">
+    <Call name="addHandler">
+      <Arg>
+        <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
+          <Set name="requestLog">
+            <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
+              <Set name="filename">
+                 logs/request.yyyy_mm_dd.log
+              </Set>
+              <Set name="filenameDateFormat">yyyy_MM_dd</Set>
+              <Set name="retainDays">90</Set>
+              <Set name="append">true</Set>
+              <Set name="extended">false</Set>
+              <Set name="logCookies">false</Set>
+              <Set name="LogTimeZone">UTC</Set>
+            </New>
+          </Set>
+        </New>
+      </Arg>
+    </Call>
+  </Ref>
+</Configure>
diff --git a/solr/server/etc/jetty.xml b/solr/server/etc/jetty.xml
index ea13be0..369e531 100644
--- a/solr/server/etc/jetty.xml
+++ b/solr/server/etc/jetty.xml
@@ -182,33 +182,6 @@
     <Set name="handler">
       <Ref id="RewriteHandler"/>
     </Set>
-    
-    <!-- =========================================================== -->
-    <!-- Configure Request Log                                       -->
-    <!-- =========================================================== -->
-    <!--
-    <Ref id="Handlers">
-      <Call name="addHandler">
-        <Arg>
-          <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
-            <Set name="requestLog">
-              <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
-                <Set name="filename">
-                   logs/request.yyyy_mm_dd.log
-                </Set>
-                <Set name="filenameDateFormat">yyyy_MM_dd</Set>
-                <Set name="retainDays">90</Set>
-                <Set name="append">true</Set>
-                <Set name="extended">false</Set>
-                <Set name="logCookies">false</Set>
-                <Set name="LogTimeZone">UTC</Set>
-              </New>
-            </Set>
-          </New>
-        </Arg>
-      </Call>
-    </Ref>
-    -->
 
     <!-- =========================================================== -->
     <!-- extra options                                               -->
diff --git a/solr/server/modules/requestlog.mod b/solr/server/modules/requestlog.mod
new file mode 100644
index 0000000..2b048db
--- /dev/null
+++ b/solr/server/modules/requestlog.mod
@@ -0,0 +1,9 @@
+#
+# Request Log module
+#
+
+[depend]
+server
+
+[xml]
+etc/jetty-requestlog.xml