From 1425d6cbf853a8ab8998f95b6982c065d9bac1c7 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 23 Dec 2019 10:37:31 -0500 Subject: [PATCH] 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(-) create mode 100644 solr/server/etc/jetty-requestlog.xml create mode 100644 solr/server/modules/requestlog.mod diff --git a/solr/bin/solr b/solr/bin/solr index 8a3a3ac61b3..8cdd1145057 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 974d7e1272a..c94f3c16b61 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 e46233672d3..c6cc5b99707 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 d4e6b7bb668..c47afc47978 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 00000000000..34a1e90200a --- /dev/null +++ b/solr/server/etc/jetty-requestlog.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + /yyyy_mm_dd.request.log + yyyy_MM_dd + 90 + true + UTC + + + + + + + + diff --git a/solr/server/etc/jetty.xml b/solr/server/etc/jetty.xml index ea13be05884..e8c8dd2bd40 100644 --- a/solr/server/etc/jetty.xml +++ b/solr/server/etc/jetty.xml @@ -167,9 +167,6 @@ - - - @@ -182,33 +179,6 @@ - - - - - diff --git a/solr/server/modules/requestlog.mod b/solr/server/modules/requestlog.mod new file mode 100644 index 00000000000..2b048dbc767 --- /dev/null +++ b/solr/server/modules/requestlog.mod @@ -0,0 +1,9 @@ +# +# Request Log module +# + +[depend] +server + +[xml] +etc/jetty-requestlog.xml