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/23 15:41:49 UTC

[lucene-solr] branch branch_8x updated: SOLR-14138: enable request log via environ var, remove deprecated jetty class usage, respect SOLR_LOGS_DIR (#1110)

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

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


The following commit(s) were added to refs/heads/branch_8x by this push:
     new baeaa56  SOLR-14138: enable request log via environ var, remove deprecated jetty class usage, respect SOLR_LOGS_DIR (#1110)
baeaa56 is described below

commit baeaa56fb27efe41b9c41d35a93d086b2a9d7cb4
Author: Robert Muir <rm...@apache.org>
AuthorDate: Mon Dec 23 10:37:31 2019 -0500

    SOLR-14138: enable request log via environ var, remove deprecated jetty class usage, respect SOLR_LOGS_DIR (#1110)
    
    User can now set SOLR_REQUESTLOG_ENABLED=true to enable the jetty request log, instead of editing XML. The location of the request logs will respect SOLR_LOGS_DIR if that is set. The deprecated NCSARequestLog is no longer used, instead it uses CustomRequestLog with NCSA_FORMAT.
---
 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 | 43 ++++++++++++++++++++++++++++++++++++
 solr/server/etc/jetty.xml            | 30 -------------------------
 solr/server/modules/requestlog.mod   |  9 ++++++++
 7 files changed, 68 insertions(+), 30 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..34a1e90
--- /dev/null
+++ b/solr/server/etc/jetty-requestlog.xml
@@ -0,0 +1,43 @@
+<?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">
+  <Set name="RequestLog">
+    <New id="RequestLog" class="org.eclipse.jetty.server.CustomRequestLog">
+      <!-- Writer -->
+      <Arg>
+        <New class="org.eclipse.jetty.server.AsyncRequestLogWriter">
+          <Arg><Property name="solr.log.dir" default="logs"/>/yyyy_mm_dd.request.log</Arg>
+          <Set name="filenameDateFormat">yyyy_MM_dd</Set>
+          <Set name="retainDays">90</Set>
+          <Set name="append">true</Set>
+          <Set name="timeZone">UTC</Set>
+        </New>
+      </Arg>
+
+      <!-- Format String -->
+      <Arg><Get class="org.eclipse.jetty.server.CustomRequestLog" name="NCSA_FORMAT"/></Arg>
+    </New>
+  </Set>
+</Configure>
diff --git a/solr/server/etc/jetty.xml b/solr/server/etc/jetty.xml
index ea13be0..e8c8dd2 100644
--- a/solr/server/etc/jetty.xml
+++ b/solr/server/etc/jetty.xml
@@ -167,9 +167,6 @@
                    </Set>
                  </New>
                </Item>
-               <Item>
-                 <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
-               </Item>
              </Array>
            </Set>
          </New>
@@ -182,33 +179,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