You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2018/03/26 02:16:40 UTC
[3/3] lucene-solr:master: SOLR-7887: Upgrade Solr to use log4j2 --
log4j 1 now officially end of life
SOLR-7887: Upgrade Solr to use log4j2 -- log4j 1 now officially end of life
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/624d128b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/624d128b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/624d128b
Branch: refs/heads/master
Commit: 624d128b5e745d88adb54bc8505e96cdf6156209
Parents: 4bb02d8
Author: Erick Erickson <er...@apache.org>
Authored: Sun Mar 25 19:16:09 2018 -0700
Committer: Erick Erickson <er...@apache.org>
Committed: Sun Mar 25 19:16:09 2018 -0700
----------------------------------------------------------------------
lucene/common-build.xml | 3 +-
lucene/ivy-versions.properties | 12 +-
solr/CHANGES.txt | 5 +
solr/bin/install_solr_service.sh | 8 +-
solr/bin/solr | 8 +-
solr/bin/solr.cmd | 52 ++--
solr/bin/solr.in.cmd | 2 +-
solr/bin/solr.in.sh | 8 +-
.../clustering/src/test-files/log4j.properties | 10 -
.../clustering/src/test-files/log4j2.xml | 37 +++
.../src/test-files/log4j.properties | 9 -
.../dataimporthandler/src/test-files/log4j2.xml | 36 +++
.../contrib/ltr/src/test-files/log4j.properties | 32 --
solr/contrib/ltr/src/test-files/log4j2.xml | 41 +++
solr/contrib/prometheus-exporter/ivy.xml | 5 +-
solr/core/ivy.xml | 8 +-
.../client/solrj/embedded/JettySolrRunner.java | 2 +-
.../solr/handler/admin/LoggingHandler.java | 4 +-
.../org/apache/solr/logging/LogWatcher.java | 16 +-
.../solr/logging/log4j/EventAppender.java | 48 ---
.../apache/solr/logging/log4j/Log4jInfo.java | 52 ----
.../apache/solr/logging/log4j/Log4jWatcher.java | 171 -----------
.../apache/solr/logging/log4j/package-info.java | 23 --
.../solr/logging/log4j2/Log4j2Watcher.java | 289 +++++++++++++++++++
.../solr/logging/log4j2/package-info.java | 22 ++
.../apache/solr/servlet/SolrDispatchFilter.java | 1 +
.../src/java/org/apache/solr/util/SolrCLI.java | 2 +-
.../org/apache/solr/util/SolrLogLayout.java | 69 +++--
.../apache/solr/util/StartupLoggingUtils.java | 39 ++-
solr/core/src/test-files/log4j.properties | 38 ---
solr/core/src/test-files/log4j2.xml | 39 +++
.../apache/solr/handler/RequestLoggingTest.java | 42 ++-
.../solr/handler/admin/LoggingHandlerTest.java | 34 ++-
.../org/apache/solr/logging/TestLogWatcher.java | 21 ++
.../reporters/SolrSlf4jReporterTest.java | 7 +-
.../apache/solr/util/TestSolrCLIRunExample.java | 3 +
solr/example/README.txt | 2 +-
.../example-DIH/solr/db/conf/solrconfig.xml | 2 +-
.../example-DIH/solr/mail/conf/solrconfig.xml | 2 +-
.../example-DIH/solr/solr/conf/solrconfig.xml | 2 +-
solr/example/resources/log4j.properties | 24 --
solr/example/resources/log4j2.xml | 53 ++++
solr/licenses/disruptor-3.4.0.jar.sha1 | 1 +
solr/licenses/disruptor-LICENSE-ASL.txt | 201 +++++++++++++
solr/licenses/disruptor-NOTICE.txt | 0
solr/licenses/log4j-1.2-api-2.11.0.jar.sha1 | 1 +
solr/licenses/log4j-1.2.17.jar.sha1 | 1 -
solr/licenses/log4j-api-2.11.0.jar.sha1 | 1 +
solr/licenses/log4j-api-LICENSE-ASL.txt | 201 +++++++++++++
solr/licenses/log4j-api-NOTICE.txt | 17 ++
solr/licenses/log4j-core-2.11.0.jar.sha1 | 1 +
solr/licenses/log4j-core-LICENSE-ASL.txt | 201 +++++++++++++
solr/licenses/log4j-core-NOTICE.txt | 17 ++
solr/licenses/log4j-slf4j-LICENSE-ASL.txt | 201 +++++++++++++
solr/licenses/log4j-slf4j-NOTICE.txt | 17 ++
solr/licenses/log4j-slf4j-impl-2.11.0.jar.sha1 | 1 +
solr/licenses/slf4j-log4j12-1.7.24.jar.sha1 | 1 -
solr/server/README.txt | 4 +-
solr/server/ivy.xml | 9 +-
solr/server/resources/log4j.properties | 29 --
solr/server/resources/log4j2.xml | 53 ++++
.../scripts/cloud-scripts/log4j.properties | 12 -
solr/server/scripts/cloud-scripts/log4j2.xml | 37 +++
.../scripts/cloud-scripts/snapshotscli.sh | 4 +-
solr/server/scripts/cloud-scripts/zkcli.bat | 4 +-
solr/server/scripts/cloud-scripts/zkcli.sh | 4 +-
.../conf/solrconfig.xml | 2 +-
solr/solr-ref-guide/ivy.xml | 4 +-
.../solr-ref-guide/src/configuring-logging.adoc | 8 +-
.../src/solr-control-script-reference.adoc | 4 +-
.../src/taking-solr-to-production.adoc | 4 +-
solr/solrj/ivy.xml | 2 +-
solr/solrj/src/test-files/log4j.properties | 32 --
solr/solrj/src/test-files/log4j2.xml | 39 +++
.../java/org/apache/solr/SolrTestCaseJ4.java | 9 +-
.../src/java/org/apache/solr/util/LogLevel.java | 47 +--
.../src/test-files/log4j.properties | 11 -
solr/test-framework/src/test-files/log4j2.xml | 39 +++
.../apache/solr/TestLogLevelAnnotations.java | 16 +-
79 files changed, 1838 insertions(+), 680 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/lucene/common-build.xml
----------------------------------------------------------------------
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 86e4288..1061a54 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -187,7 +187,8 @@
<property name="javadoc.noindex" value="true"/>
<property name="javadoc.doclint.args" value="-Xdoclint:all -Xdoclint:-missing"/>
- <property name="javac.doclint.args" value="-Xdoclint:all/protected -Xdoclint:-missing"/>
+ <!---proc:none was added because of LOG4J2-1925 / JDK-8186647 -->
+ <property name="javac.doclint.args" value="-Xdoclint:all/protected -Xdoclint:-missing -proc:none"/>
<!-- Javadoc classpath -->
<path id="javadoc.classpath">
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/lucene/ivy-versions.properties
----------------------------------------------------------------------
diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index afbab20..58d21d0 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -32,6 +32,7 @@ com.fasterxml.jackson.core.version = 2.5.4
/com.healthmarketscience.jackcess/jackcess = 2.1.8
/com.healthmarketscience.jackcess/jackcess-encrypt = 2.1.4
/com.ibm.icu/icu4j = 59.1
+/com.lmax/disruptor = 3.4.0
/com.pff/java-libpst = 0.8.1
com.rometools.version = 1.5.1
@@ -84,8 +85,9 @@ io.prometheus.version = 0.2.0
/junit/junit = 4.10
# NOTE: split out from the full version to also use as solr-ref-guide attribute
-org.log4j.major.version = 1.2
-/log4j/log4j = ${org.log4j.major.version}.17
+org.log4j.major.version = 2.11
+org.log4j.minor.version = 0
+org.apache.logging.log4j.version = ${org.log4j.major.version}.${org.log4j.minor.version}
/mecab/mecab-ipadic = 2.7.0-20070801
/mecab/mecab-naist-jdic = 0.6.3b-20111013
@@ -180,6 +182,11 @@ org.apache.james.apache.mime4j.version = 0.8.1
/org.apache.james/apache-mime4j-core = ${org.apache.james.apache.mime4j.version}
/org.apache.james/apache-mime4j-dom = ${org.apache.james.apache.mime4j.version}
+/org.apache.logging.log4j/log4j-1.2-api = ${org.apache.logging.log4j.version}
+/org.apache.logging.log4j/log4j-api = ${org.apache.logging.log4j.version}
+/org.apache.logging.log4j/log4j-core = ${org.apache.logging.log4j.version}
+/org.apache.logging.log4j/log4j-slf4j-impl = ${org.apache.logging.log4j.version}
+
/org.apache.mina/mina-core = 2.0.0-M5
/org.apache.opennlp/opennlp-maxent = 3.0.3
@@ -301,7 +308,6 @@ org.slf4j.version = 1.7.24
/org.slf4j/jcl-over-slf4j = ${org.slf4j.version}
/org.slf4j/jul-to-slf4j = ${org.slf4j.version}
/org.slf4j/slf4j-api = ${org.slf4j.version}
-/org.slf4j/slf4j-log4j12 = ${org.slf4j.version}
/org.slf4j/slf4j-simple = ${org.slf4j.version}
/org.tallison/jmatio = 1.2
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9268315..865fecf 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -166,6 +166,9 @@ Upgrade Notes
from the earlier default of 30 seconds. This affects how soon Solr adds new replicas to replace the replicas
on nodes which have either crashed or shutdown.
+* SOLR-7887: Solr now uses Log4J 2.10. The log4j configuration is now in log4j2.xml rather than lo4j.properties
+ files (Shawn Heisey, Keith Laban, Timothy Potter, Varun Thacker, Erick Erickson,
+
New Features
----------------------
* SOLR-11285: Simulation framework for autoscaling. (ab)
@@ -489,6 +492,8 @@ Other Changes
* SOLR-12097: Document the diskType policy attribute and usage of disk space in Collection APIs.
(Cassandra Targett, shalin)
+* SOLR-7887: Upgrade Solr to Log4J 2.10 (Tim Potter, Keith Laban, Shawn Heisey, Ralph Goers, Varun Thacker)
+
================== 7.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/bin/install_solr_service.sh
----------------------------------------------------------------------
diff --git a/solr/bin/install_solr_service.sh b/solr/bin/install_solr_service.sh
index b829571..033b383 100755
--- a/solr/bin/install_solr_service.sh
+++ b/solr/bin/install_solr_service.sh
@@ -326,7 +326,7 @@ else
mv "$SOLR_INSTALL_DIR/bin/solr.in.cmd" "$SOLR_INSTALL_DIR/bin/solr.in.cmd.orig"
echo "SOLR_PID_DIR=\"$SOLR_VAR_DIR\"
SOLR_HOME=\"$SOLR_VAR_DIR/data\"
-LOG4J_PROPS=\"$SOLR_VAR_DIR/log4j.properties\"
+LOG4J_PROPS=\"$SOLR_VAR_DIR/log4j2.xml\"
SOLR_LOGS_DIR=\"$SOLR_VAR_DIR/logs\"
SOLR_PORT=\"$SOLR_PORT\"
" >> "/etc/default/$SOLR_SERVICE.in.sh"
@@ -342,10 +342,10 @@ if [ -f "$SOLR_VAR_DIR/data/solr.xml" ]; then
else
cp "$SOLR_INSTALL_DIR/server/solr/"{solr.xml,zoo.cfg} "$SOLR_VAR_DIR/data/"
fi
-if [ -f "$SOLR_VAR_DIR/log4j.properties" ]; then
- echo -e "\n$SOLR_VAR_DIR/log4j.properties already exists. Skipping install ...\n"
+if [ -f "$SOLR_VAR_DIR/log4j2.xml" ]; then
+ echo -e "\n$SOLR_VAR_DIR/log4j2.xml already exists. Skipping install ...\n"
else
- cp "$SOLR_INSTALL_DIR/server/resources/log4j.properties" "$SOLR_VAR_DIR/log4j.properties"
+ cp "$SOLR_INSTALL_DIR/server/resources/log4j2.xml" "$SOLR_VAR_DIR/log4j2.xml"
fi
chown -R "$SOLR_USER:" "$SOLR_VAR_DIR"
find "$SOLR_VAR_DIR" -type d -print0 | xargs -0 chmod 0750
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index 47861ad..e05d570 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -681,7 +681,7 @@ function jetty_port() {
function run_tool() {
"$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS $SOLR_ZK_CREDS_AND_ACLS -Dsolr.install.dir="$SOLR_TIP" \
- -Dlog4j.configuration="file:$DEFAULT_SERVER_DIR/scripts/cloud-scripts/log4j.properties" \
+ -Dlog4j.configurationFile="file:$DEFAULT_SERVER_DIR/scripts/cloud-scripts/log4j2.xml" \
-classpath "$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*:$DEFAULT_SERVER_DIR/lib/ext/*" \
org.apache.solr.util.SolrCLI "$@"
@@ -1783,20 +1783,20 @@ if [ -z "$DEFAULT_CONFDIR" ]; then
DEFAULT_CONFDIR="$SOLR_SERVER_DIR/solr/configsets/_default/conf"
fi
-# This is quite hacky, but examples rely on a different log4j.properties
+# This is quite hacky, but examples rely on a different log4j2.xml
# so that we can write logs for examples to $SOLR_HOME/../logs
if [ -z "$SOLR_LOGS_DIR" ]; then
SOLR_LOGS_DIR="$SOLR_SERVER_DIR/logs"
fi
EXAMPLE_DIR="$SOLR_TIP/example"
if [ "${SOLR_HOME:0:${#EXAMPLE_DIR}}" = "$EXAMPLE_DIR" ]; then
- LOG4J_PROPS="$EXAMPLE_DIR/resources/log4j.properties"
+ LOG4J_PROPS="$EXAMPLE_DIR/resources/log4j2.xml"
SOLR_LOGS_DIR="$SOLR_HOME/../logs"
fi
LOG4J_CONFIG=()
if [ -n "$LOG4J_PROPS" ]; then
- LOG4J_CONFIG+=("-Dlog4j.configuration=file:$LOG4J_PROPS")
+ LOG4J_CONFIG+=("-Dlog4j.configurationFile=file:$LOG4J_PROPS")
fi
if [ "$SCRIPT_CMD" == "stop" ]; then
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/bin/solr.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index dcff0c6..ab32d23 100644
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -935,7 +935,7 @@ IF NOT EXIST "%SOLR_HOME%\" (
IF "%STOP_KEY%"=="" set STOP_KEY=solrrocks
-@REM This is quite hacky, but examples rely on a different log4j.properties
+@REM This is quite hacky, but examples rely on a different log4j2.xml
@REM so that we can write logs for examples to %SOLR_HOME%\..\logs
IF [%SOLR_LOGS_DIR%] == [] (
set "SOLR_LOGS_DIR=%SOLR_SERVER_DIR%\logs"
@@ -949,7 +949,7 @@ set "EXAMPLE_DIR=%SOLR_TIP%\example"
set TMP=!SOLR_HOME:%EXAMPLE_DIR%=!
IF NOT "%TMP%"=="%SOLR_HOME%" (
set "SOLR_LOGS_DIR=%SOLR_HOME%\..\logs"
- set "LOG4J_CONFIG=file:%EXAMPLE_DIR%\resources\log4j.properties"
+ set "LOG4J_CONFIG=file:%EXAMPLE_DIR%\resources\log4j2.xml"
)
set IS_RESTART=0
@@ -977,7 +977,7 @@ IF "%SCRIPT_CMD%"=="stop" (
IF "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
set found_it=1
@echo Stopping Solr process %%k running on port !SOME_SOLR_PORT!
- IF "%STOP_PORT%"=="" set /A STOP_PORT=!SOME_SOLR_PORT! - 1000
+ IF "%STOP_PORT%"=="" set /A STOP_PORT=!SOME_SOLR_PORT! - 1000
"%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port
timeout /T 5
@@ -1007,7 +1007,7 @@ IF "%SCRIPT_CMD%"=="stop" (
IF "%%M"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
set found_it=1
@echo Stopping Solr process %%N running on port %SOLR_PORT%
- IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
+ IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
"%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" "%SOLR_JETTY_CONFIG%" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
del "%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
timeout /T 5
@@ -1221,7 +1221,7 @@ IF "%SOLR_SSL_ENABLED%"=="true" (
IF NOT "%SOLR_LOG_LEVEL%"=="" set "START_OPTS=%START_OPTS% -Dsolr.log.level=%SOLR_LOG_LEVEL%"
set "START_OPTS=%START_OPTS% -Dsolr.log.dir=%SOLR_LOGS_DIR_QUOTED%"
IF NOT "%SOLR_DATA_HOME%"=="" set "START_OPTS=%START_OPTS% -Dsolr.data.home=%SOLR_DATA_HOME_QUOTED%"
-IF NOT DEFINED LOG4J_CONFIG set "LOG4J_CONFIG=file:%SOLR_SERVER_DIR%\resources\log4j.properties"
+IF NOT DEFINED LOG4J_CONFIG set "LOG4J_CONFIG=file:%SOLR_SERVER_DIR%\resources\log4j2.xml"
cd /d "%SOLR_SERVER_DIR%"
@@ -1253,14 +1253,14 @@ IF "%FG%"=="1" (
title "Solr-%SOLR_PORT%"
echo %SOLR_PORT%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
"%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^
- -Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
+ -Dlog4j.configurationFile="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
-Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%" ^
-Djetty.host=%SOLR_JETTY_HOST% -Djetty.port=%SOLR_PORT% -Djetty.home="%SOLR_SERVER_DIR%" ^
-Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar "%SOLR_JETTY_CONFIG%" "%SOLR_JETTY_ADDL_CONFIG%"
) ELSE (
START /B "Solr-%SOLR_PORT%" /D "%SOLR_SERVER_DIR%" ^
"%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^
- -Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
+ -Dlog4j.configurationFile="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
-Dsolr.log.muteconsole ^
-Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%" ^
-Djetty.host=%SOLR_JETTY_HOST% -Djetty.port=%SOLR_PORT% -Djetty.home="%SOLR_SERVER_DIR%" ^
@@ -1269,7 +1269,7 @@ IF "%FG%"=="1" (
REM now wait to see Solr come online ...
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%"^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI status -maxWaitSecs 30 -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr
)
@@ -1280,7 +1280,7 @@ goto done
REM Run the requested example
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI run_example -script "%SDIR%\solr.cmd" -e %EXAMPLE% -d "%SOLR_SERVER_DIR%" ^
-urlScheme !SOLR_URL_SCHEME! !PASS_TO_RUN_EXAMPLE!
@@ -1302,7 +1302,7 @@ for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port
set has_info=1
echo Found Solr process %%k running on port !SOME_SOLR_PORT!
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI status -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!SOME_SOLR_PORT!/solr
@echo.
@@ -1349,14 +1349,14 @@ IF NOT DEFINED HEALTHCHECK_COLLECTION goto healthcheck_usage
IF NOT DEFINED HEALTHCHECK_VERBOSE set "HEALTHCHECK_VERBOSE="
IF NOT DEFINED HEALTHCHECK_ZK_HOST set "HEALTHCHECK_ZK_HOST=localhost:9983"
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI healthcheck -collection !HEALTHCHECK_COLLECTION! -zkHost !HEALTHCHECK_ZK_HOST! %HEALTHCHECK_VERBOSE%
goto done
:run_assert
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI %*
if errorlevel 1 (
@@ -1366,7 +1366,7 @@ goto done
:run_config
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI %*
if errorlevel 1 (
@@ -1376,7 +1376,7 @@ goto done
:get_version
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI version
goto done
@@ -1386,7 +1386,7 @@ set "TOOL_CMD=%~1"
set q="-q"
IF "%verbose%"=="1" set q=""
"%JAVA%" %SOLR_SSL_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI utils -s "%DEFAULT_SERVER_DIR%" -l "%SOLR_LOGS_DIR%" %q:"=% %TOOL_CMD%
if errorlevel 1 (
@@ -1492,13 +1492,13 @@ if "!CREATE_CONFDIR!"=="_default" (
if "%SCRIPT_CMD%"=="create_core" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr ^
-confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" %CREATE_VERBOSE%
) else (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%"^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI create -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^
-confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" ^
@@ -1573,7 +1573,7 @@ if "!DELETE_CONFIG!"=="" (
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
--Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+-Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI delete -name !DELETE_NAME! -deleteConfig !DELETE_CONFIG! ^
-solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!DELETE_PORT!/solr %DELETE_VERBOSE%
@@ -1709,7 +1709,7 @@ IF "!ZK_OP!"=="upconfig" (
goto zk_short_usage
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! %ZK_VERBOSE%^
-configsetsDir "%SOLR_TIP%/server/solr/configsets"
@@ -1723,7 +1723,7 @@ IF "!ZK_OP!"=="upconfig" (
goto zk_short_usage
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="cp" (
@@ -1742,7 +1742,7 @@ IF "!ZK_OP!"=="upconfig" (
)
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! -recurse !ZK_RECURSE! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="mv" (
@@ -1755,7 +1755,7 @@ IF "!ZK_OP!"=="upconfig" (
goto zk_short_usage
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="rm" (
@@ -1764,7 +1764,7 @@ IF "!ZK_OP!"=="upconfig" (
goto zk_short_usage
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="ls" (
@@ -1773,7 +1773,7 @@ IF "!ZK_OP!"=="upconfig" (
goto zk_short_usage
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="mkroot" (
@@ -1782,7 +1782,7 @@ IF "!ZK_OP!"=="upconfig" (
goto zk_short_usage
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! %ZK_VERBOSE%
) ELSE (
@@ -1843,7 +1843,7 @@ if "!AUTH_PORT!"=="" (
)
)
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
- -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+ -Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI auth %AUTH_PARAMS% -solrIncludeFile "%SOLR_INCLUDE%" -authConfDir "%SOLR_HOME%" ^
-solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!AUTH_PORT!/solr
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/bin/solr.in.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmd
index bfb33e0..6f7867f 100644
--- a/solr/bin/solr.in.cmd
+++ b/solr/bin/solr.in.cmd
@@ -78,7 +78,7 @@ REM If not set, defaults to <instance_dir>/data. Overridable per core through 'd
REM set SOLR_DATA_HOME=
REM Changes the logging level. Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. Default is INFO
-REM This is an alternative to changing the rootLogger in log4j.properties
+REM This is an alternative to changing the rootLogger in log4j2.xml
REM set SOLR_LOG_LEVEL=INFO
REM Location where Solr should write logs to. Absolute or relative to solr start dir
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/bin/solr.in.sh
----------------------------------------------------------------------
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index e7478cd..d023b38 100644
--- a/solr/bin/solr.in.sh
+++ b/solr/bin/solr.in.sh
@@ -93,13 +93,13 @@
# If not set, defaults to <instance_dir>/data. Overridable per core through 'dataDir' core property
#SOLR_DATA_HOME=
-# Solr provides a default Log4J configuration properties file in server/resources
+# Solr provides a default Log4J configuration xml file in server/resources
# however, you may want to customize the log settings and file appender location
-# so you can point the script to use a different log4j.properties file
-#LOG4J_PROPS=/var/solr/log4j.properties
+# so you can point the script to use a different log4j2.xml file
+#LOG4J_PROPS=/var/solr/log4j2.xml
# Changes the logging level. Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. Default is INFO
-# This is an alternative to changing the rootLogger in log4j.properties
+# This is an alternative to changing the rootLogger in log4j2.xml
#SOLR_LOG_LEVEL=INFO
# Location where Solr should write logs to. Absolute or relative to solr start dir
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/clustering/src/test-files/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/contrib/clustering/src/test-files/log4j.properties b/solr/contrib/clustering/src/test-files/log4j.properties
deleted file mode 100644
index b5216db..0000000
--- a/solr/contrib/clustering/src/test-files/log4j.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-# Logging level
-log4j.rootLogger=INFO, CONSOLE
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.err
-log4j.appender.CONSOLE.layout=org.apache.solr.util.SolrLogLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m%n
-
-log4j.logger.org.apache.zookeeper=WARN
-log4j.logger.org.apache.hadoop=WARN
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/clustering/src/test-files/log4j2.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/clustering/src/test-files/log4j2.xml b/solr/contrib/clustering/src/test-files/log4j2.xml
new file mode 100644
index 0000000..9b2a029
--- /dev/null
+++ b/solr/contrib/clustering/src/test-files/log4j2.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %c; %m%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+ <Logger name="org.apache.hadoop" level="WARN"/>
+
+ <Root level="INFO">
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/dataimporthandler/src/test-files/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/contrib/dataimporthandler/src/test-files/log4j.properties b/solr/contrib/dataimporthandler/src/test-files/log4j.properties
deleted file mode 100644
index d3ea4de..0000000
--- a/solr/contrib/dataimporthandler/src/test-files/log4j.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-# Logging level
-log4j.rootLogger=INFO, CONSOLE
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.err
-log4j.appender.CONSOLE.layout=org.apache.solr.util.SolrLogLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m%n
-
-log4j.logger.org.apache.zookeeper=WARN
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/dataimporthandler/src/test-files/log4j2.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/dataimporthandler/src/test-files/log4j2.xml b/solr/contrib/dataimporthandler/src/test-files/log4j2.xml
new file mode 100644
index 0000000..fd74d4e
--- /dev/null
+++ b/solr/contrib/dataimporthandler/src/test-files/log4j2.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %c; %m%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+
+ <Root level="INFO">
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/ltr/src/test-files/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test-files/log4j.properties b/solr/contrib/ltr/src/test-files/log4j.properties
deleted file mode 100644
index d86c698..0000000
--- a/solr/contrib/ltr/src/test-files/log4j.properties
+++ /dev/null
@@ -1,32 +0,0 @@
-# Logging level
-log4j.rootLogger=INFO, CONSOLE
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.err
-log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p (%t) [%X{node_name} %X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
-log4j.logger.org.apache.zookeeper=WARN
-log4j.logger.org.apache.hadoop=WARN
-log4j.logger.org.apache.directory=WARN
-log4j.logger.org.apache.solr.hadoop=INFO
-log4j.logger.org.apache.solr.client.solrj.embedded.JettySolrRunner=DEBUG
-org.apache.solr.client.solrj.embedded.JettySolrRunner=DEBUG
-
-#log4j.logger.org.apache.solr.update.processor.LogUpdateProcessor=DEBUG
-#log4j.logger.org.apache.solr.update.processor.DistributedUpdateProcessor=DEBUG
-#log4j.logger.org.apache.solr.update.PeerSync=DEBUG
-#log4j.logger.org.apache.solr.core.CoreContainer=DEBUG
-#log4j.logger.org.apache.solr.cloud.RecoveryStrategy=DEBUG
-#log4j.logger.org.apache.solr.cloud.SyncStrategy=DEBUG
-#log4j.logger.org.apache.solr.handler.admin.CoreAdminHandler=DEBUG
-#log4j.logger.org.apache.solr.cloud.ZkController=DEBUG
-#log4j.logger.org.apache.solr.update.DefaultSolrCoreState=DEBUG
-#log4j.logger.org.apache.solr.common.cloud.ConnectionManager=DEBUG
-#log4j.logger.org.apache.solr.update.UpdateLog=DEBUG
-#log4j.logger.org.apache.solr.cloud.ChaosMonkey=DEBUG
-#log4j.logger.org.apache.solr.update.TransactionLog=DEBUG
-#log4j.logger.org.apache.solr.handler.ReplicationHandler=DEBUG
-#log4j.logger.org.apache.solr.handler.IndexFetcher=DEBUG
-
-#log4j.logger.org.apache.solr.common.cloud.ClusterStateUtil=DEBUG
-#log4j.logger.org.apache.solr.cloud.OverseerAutoReplicaFailoverThread=DEBUG
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/ltr/src/test-files/log4j2.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test-files/log4j2.xml b/solr/contrib/ltr/src/test-files/log4j2.xml
new file mode 100644
index 0000000..5acf4d0
--- /dev/null
+++ b/solr/contrib/ltr/src/test-files/log4j2.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %-4r %-5p (%t) [%X{node_name} %X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+ <Logger name="org.apache.hadoop" level="WARN"/>
+ <Logger name="org.apache.directory" level="WARN"/>
+ <Logger name="org.apache.solr.hadoop" level="INFO"/>
+ <Logger name="log4j.logger.org.apache.solr.hadoop" level="INFO"/>
+ <Logger name="org.apache.solr.client.solrj.embedded.JettySolrRunner" level="DEBUG"/>
+
+ <Root level="INFO">
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/contrib/prometheus-exporter/ivy.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/ivy.xml b/solr/contrib/prometheus-exporter/ivy.xml
index a8f8894..2c67825 100644
--- a/solr/contrib/prometheus-exporter/ivy.xml
+++ b/solr/contrib/prometheus-exporter/ivy.xml
@@ -32,8 +32,9 @@
<dependency org="net.thisptr" name="jackson-jq" rev="${/net.thisptr/jackson-jq}" conf="compile"/>
<dependency org="net.sourceforge.argparse4j" name="argparse4j" rev="${/net.sourceforge.argparse4j/argparse4j}" conf="compile"/>
<dependency org="org.slf4j" name="slf4j-api" rev="${/org.slf4j/slf4j-api}" conf="compile"/>
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="${/org.slf4j/slf4j-log4j12}" conf="compile"/>
- <dependency org="log4j" name="log4j" rev="${/log4j/log4j}" conf="compile"/>
+ <dependency org="org.apache.logging.log4j" name="log4j-slf4j-impl" rev="${/org.apache.logging.log4j/log4j-slf4j-impl}" conf="test"/>
+ <dependency org="org.apache.logging.log4j" name="log4j-api" rev="${/org.apache.logging.log4j/log4j-api}" conf="compile"/>
+ <dependency org="org.apache.logging.log4j" name="log4j-core" rev="${/org.apache.logging.log4j/log4j-core}" conf="compile"/>
<exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
</dependencies>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/ivy.xml
----------------------------------------------------------------------
diff --git a/solr/core/ivy.xml b/solr/core/ivy.xml
index ff4fa48..e47d5b8 100644
--- a/solr/core/ivy.xml
+++ b/solr/core/ivy.xml
@@ -47,8 +47,12 @@
<dependency org="joda-time" name="joda-time" rev="${/joda-time/joda-time}" conf="compile"/>
<dependency org="dom4j" name="dom4j" rev="${/dom4j/dom4j}" conf="compile"/>
<dependency org="com.carrotsearch" name="hppc" rev="${/com.carrotsearch/hppc}" conf="compile"/>
- <dependency org="log4j" name="log4j" rev="${/log4j/log4j}" conf="compile"/>
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="${/org.slf4j/slf4j-log4j12}" conf="compile"/>
+
+ <dependency org="org.apache.logging.log4j" name="log4j-api" rev="${/org.apache.logging.log4j/log4j-api}" conf="compile"/>
+ <dependency org="org.apache.logging.log4j" name="log4j-core" rev="${/org.apache.logging.log4j/log4j-core}" conf="compile"/>
+ <dependency org="org.apache.logging.log4j" name="log4j-slf4j-impl" rev="${/org.apache.logging.log4j/log4j-slf4j-impl}" conf="compile"/>
+ <dependency org="org.apache.logging.log4j" name="log4j-1.2-api" rev="${/org.apache.logging.log4j/log4j-1.2-api}" conf="compile"/>
+ <dependency org="com.lmax" name="disruptor" rev="${/com.lmax/disruptor}" conf="compile"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="${/org.slf4j/jcl-over-slf4j}" conf="compile"/>
<dependency org="org.mockito" name="mockito-core" rev="${/org.mockito/mockito-core}" conf="test"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
index 23a8dc1..745341a 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
@@ -363,7 +363,7 @@ public class JettySolrRunner {
*
* If the server has been started before, it will restart using the same port
*
- * @throws Exception if an error occurs on startup
+ * @throws java.lang.Exception if an error occurs on startup
*/
public void start() throws Exception {
start(true);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
index 122d2cb..ef52636 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
@@ -67,7 +67,7 @@ public class LoggingHandler extends RequestHandlerBase implements SolrCoreAware
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
// Don't do anything if the framework is unknown
- if(watcher==null) {
+ if (watcher==null) {
rsp.add("error", "Logging Not Initialized");
return;
}
@@ -142,7 +142,7 @@ public class LoggingHandler extends RequestHandlerBase implements SolrCoreAware
Collections.sort(loggers);
List<SimpleOrderedMap<?>> info = new ArrayList<>();
- for(LoggerInfo wrap:loggers) {
+ for (LoggerInfo wrap : loggers) {
info.add(wrap.getInfo());
}
rsp.add("loggers", info);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/LogWatcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/LogWatcher.java b/solr/core/src/java/org/apache/solr/logging/LogWatcher.java
index c510590..86ea8cf 100644
--- a/solr/core/src/java/org/apache/solr/logging/LogWatcher.java
+++ b/solr/core/src/java/org/apache/solr/logging/LogWatcher.java
@@ -20,7 +20,7 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.logging.jul.JulWatcher;
-import org.apache.solr.logging.log4j.Log4jWatcher;
+import org.apache.solr.logging.log4j2.Log4j2Watcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.impl.StaticLoggerBinder;
@@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
* A Class to monitor Logging events and hold N events in memory
*
- * This is abstract so we can support both JUL and Log4j (and other logging platforms)
+ * This is abstract so we can support both JUL and Log4j2 (and other logging platforms)
*/
public abstract class LogWatcher<E> {
@@ -152,8 +152,8 @@ public abstract class LogWatcher<E> {
slf4jImpl = StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr();
log.debug("SLF4J impl is " + slf4jImpl);
if (fname == null) {
- if ("org.slf4j.impl.Log4jLoggerFactory".equals(slf4jImpl)) {
- fname = "Log4j";
+ if ("org.apache.logging.slf4j.Log4jLoggerFactory".equals(slf4jImpl)) {
+ fname = "Log4j2";
} else if (slf4jImpl.indexOf("JDK") > 0) {
fname = "JUL";
}
@@ -172,10 +172,12 @@ public abstract class LogWatcher<E> {
return null;
}
- if ("JUL".equalsIgnoreCase(fname))
+ if ("JUL".equalsIgnoreCase(fname)) {
return new JulWatcher(slf4jImpl);
- if ("Log4j".equals(fname))
- return new Log4jWatcher(slf4jImpl);
+ }
+ if ("Log4j2".equals(fname)) {
+ return new Log4j2Watcher();
+ }
try {
return loader != null ? loader.newInstance(fname, LogWatcher.class) : null;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/log4j/EventAppender.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/log4j/EventAppender.java b/solr/core/src/java/org/apache/solr/logging/log4j/EventAppender.java
deleted file mode 100644
index ff2876f..0000000
--- a/solr/core/src/java/org/apache/solr/logging/log4j/EventAppender.java
+++ /dev/null
@@ -1,48 +0,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.
- */
-package org.apache.solr.logging.log4j;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.solr.common.util.SuppressForbidden;
-import org.apache.solr.logging.LogWatcher;
-
-@SuppressForbidden(reason = "class is specific to log4j")
-public final class EventAppender extends AppenderSkeleton {
-
- final LogWatcher<LoggingEvent> watcher;
-
- public EventAppender(LogWatcher<LoggingEvent> framework) {
- this.watcher = framework;
- }
-
- @Override
- public void append( LoggingEvent event )
- {
- watcher.add(event,event.timeStamp);
- }
-
- @Override
- public void close() {
- watcher.reset();
- }
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/log4j/Log4jInfo.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/log4j/Log4jInfo.java b/solr/core/src/java/org/apache/solr/logging/log4j/Log4jInfo.java
deleted file mode 100644
index dfd3dde..0000000
--- a/solr/core/src/java/org/apache/solr/logging/log4j/Log4jInfo.java
+++ /dev/null
@@ -1,52 +0,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.
- */
-package org.apache.solr.logging.log4j;
-
-import org.apache.solr.common.util.SuppressForbidden;
-import org.apache.solr.logging.LoggerInfo;
-
-@SuppressForbidden(reason = "class is specific to log4j")
-public class Log4jInfo extends LoggerInfo {
- final org.apache.log4j.Logger logger;
-
- public Log4jInfo(String name, org.apache.log4j.Logger logger) {
- super(name);
- this.logger = logger;
- }
-
- @Override
- public String getLevel() {
- if(logger==null) {
- return null;
- }
- Object level = logger.getLevel();
- if(level==null) {
- return null;
- }
- return level.toString();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean isSet() {
- return (logger!=null && logger.getLevel()!=null);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/log4j/Log4jWatcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/log4j/Log4jWatcher.java b/solr/core/src/java/org/apache/solr/logging/log4j/Log4jWatcher.java
deleted file mode 100644
index 04fa5fb..0000000
--- a/solr/core/src/java/org/apache/solr/logging/log4j/Log4jWatcher.java
+++ /dev/null
@@ -1,171 +0,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.
- */
-package org.apache.solr.logging.log4j;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.ThrowableInformation;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.util.SuppressForbidden;
-import org.apache.solr.logging.CircularList;
-import org.apache.solr.logging.ListenerConfig;
-import org.apache.solr.logging.LogWatcher;
-import org.apache.solr.logging.LoggerInfo;
-
-import com.google.common.base.Throwables;
-
-@SuppressForbidden(reason = "class is specific to log4j")
-public class Log4jWatcher extends LogWatcher<LoggingEvent> {
-
- final String name;
- AppenderSkeleton appender = null;
-
- public Log4jWatcher(String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return "Log4j ("+name+")";
- }
-
- @Override
- public List<String> getAllLevels() {
- return Arrays.asList(
- org.apache.log4j.Level.ALL.toString(),
- org.apache.log4j.Level.TRACE.toString(),
- org.apache.log4j.Level.DEBUG.toString(),
- org.apache.log4j.Level.INFO.toString(),
- org.apache.log4j.Level.WARN.toString(),
- org.apache.log4j.Level.ERROR.toString(),
- org.apache.log4j.Level.FATAL.toString(),
- org.apache.log4j.Level.OFF.toString());
- }
-
- @Override
- public void setLogLevel(String category, String level) {
- org.apache.log4j.Logger log;
- if(LoggerInfo.ROOT_NAME.equals(category)) {
- log = org.apache.log4j.LogManager.getRootLogger();
- } else {
- log = org.apache.log4j.Logger.getLogger(category);
- }
- if(level==null||"unset".equals(level)||"null".equals(level)) {
- log.setLevel(null);
- }
- else {
- log.setLevel(org.apache.log4j.Level.toLevel(level));
- }
- }
-
- @Override
- public Collection<LoggerInfo> getAllLoggers() {
- org.apache.log4j.Logger root = org.apache.log4j.LogManager.getRootLogger();
- Map<String,LoggerInfo> map = new HashMap<>();
- Enumeration<?> loggers = org.apache.log4j.LogManager.getCurrentLoggers();
- while (loggers.hasMoreElements()) {
- org.apache.log4j.Logger logger = (org.apache.log4j.Logger)loggers.nextElement();
- String name = logger.getName();
- if( logger == root) {
- continue;
- }
- map.put(name, new Log4jInfo(name, logger));
-
- while (true) {
- int dot = name.lastIndexOf(".");
- if (dot < 0)
- break;
- name = name.substring(0, dot);
- if(!map.containsKey(name)) {
- map.put(name, new Log4jInfo(name, null));
- }
- }
- }
- map.put(LoggerInfo.ROOT_NAME, new Log4jInfo(LoggerInfo.ROOT_NAME, root));
- return map.values();
- }
-
- @Override
- public void setThreshold(String level) {
- if(appender==null) {
- throw new IllegalStateException("Must have an appender");
- }
- appender.setThreshold(Level.toLevel(level));
- }
-
- @Override
- public String getThreshold() {
- if(appender==null) {
- throw new IllegalStateException("Must have an appender");
- }
- return appender.getThreshold().toString();
- }
-
- @Override
- public void registerListener(ListenerConfig cfg) {
- if(history!=null) {
- throw new IllegalStateException("History already registered");
- }
- history = new CircularList<>(cfg.size);
-
- appender = new EventAppender(this);
- if(cfg.threshold != null) {
- appender.setThreshold(Level.toLevel(cfg.threshold));
- }
- else {
- appender.setThreshold(Level.WARN);
- }
- Logger log = org.apache.log4j.LogManager.getRootLogger();
- log.addAppender(appender);
- }
-
- @Override
- public long getTimestamp(LoggingEvent event) {
- return event.timeStamp;
- }
-
- @Override
- public SolrDocument toSolrDocument(LoggingEvent event) {
- SolrDocument doc = new SolrDocument();
- doc.setField("time", new Date(event.getTimeStamp()));
- doc.setField("level", event.getLevel().toString());
- doc.setField("logger", event.getLogger().getName());
- doc.setField("message", event.getRenderedMessage());
- ThrowableInformation t = event.getThrowableInformation();
- if(t!=null) {
- doc.setField("trace", Throwables.getStackTraceAsString(t.getThrowable()));
- }
-
- // Will be null if not present
- doc.setField("core", event.getMDC(ZkStateReader.CORE_NAME_PROP));
- doc.setField("collection", event.getMDC(ZkStateReader.COLLECTION_PROP));
- doc.setField("replica", event.getMDC(ZkStateReader.REPLICA_PROP));
- doc.setField("shard", event.getMDC(ZkStateReader.SHARD_ID_PROP));
- return doc;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/log4j/package-info.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/log4j/package-info.java b/solr/core/src/java/org/apache/solr/logging/log4j/package-info.java
deleted file mode 100644
index f789533..0000000
--- a/solr/core/src/java/org/apache/solr/logging/log4j/package-info.java
+++ /dev/null
@@ -1,23 +0,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.
- */
-
-/**
- * Log4j based implementation of {@link org.apache.solr.logging.LogWatcher}
- */
-package org.apache.solr.logging.log4j;
-
-
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java b/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java
new file mode 100644
index 0000000..894ba54
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java
@@ -0,0 +1,289 @@
+/*
+ * 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.
+ */
+package org.apache.solr.logging.log4j2;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.filter.ThresholdFilter;
+import org.apache.logging.log4j.message.Message;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.logging.CircularList;
+import org.apache.solr.logging.ListenerConfig;
+import org.apache.solr.logging.LogWatcher;
+import org.apache.solr.logging.LoggerInfo;
+
+import com.google.common.base.Throwables;
+
+public class Log4j2Watcher extends LogWatcher<LogEvent> {
+
+ private final static String LOG4J2_WATCHER_APPENDER = "Log4j2WatcherAppender";
+ protected class Log4j2Appender extends AbstractAppender {
+
+ private Log4j2Watcher watcher;
+ private ThresholdFilter filter;
+ private Level threshold;
+
+ Log4j2Appender(Log4j2Watcher watcher, ThresholdFilter filter, Level threshold) {
+ super(LOG4J2_WATCHER_APPENDER, filter, null);
+ this.watcher = watcher;
+ this.filter = filter;
+ this.threshold = threshold;
+ }
+
+ public void append(LogEvent logEvent) {
+ watcher.add(logEvent, logEvent.getTimeMillis());
+ }
+
+ public Level getThreshold() {
+ return threshold;
+ }
+
+ public void setThreshold(Level threshold) {
+ this.threshold = threshold;
+ removeFilter(filter);
+ filter = ThresholdFilter.createFilter(threshold, Filter.Result.ACCEPT, Filter.Result.DENY);
+ addFilter(filter);
+ }
+ }
+
+ protected class Log4j2Info extends LoggerInfo {
+ final Level level;
+
+ Log4j2Info(String name, Level level) {
+ super(name);
+ this.level = level;
+ }
+
+ @Override
+ public String getLevel() {
+ return (level != null) ? level.toString() : null;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean isSet() {
+ return (level != null) ? true : false;
+ }
+ }
+
+ public static final Logger log = LogManager.getLogger(Log4j2Watcher.class);
+
+ protected Log4j2Appender appender = null;
+
+ @Override
+ public String getName() {
+ return "Log4j2";
+ }
+
+ @Override
+ public List<String> getAllLevels() {
+ return Arrays.asList(
+ Level.ALL.toString(),
+ Level.TRACE.toString(),
+ Level.DEBUG.toString(),
+ Level.INFO.toString(),
+ Level.WARN.toString(),
+ Level.ERROR.toString(),
+ Level.FATAL.toString(),
+ Level.OFF.toString());
+ }
+
+ @Override
+ public void setLogLevel(String loggerName, String level) {
+ assert loggerName != null;
+ assert level != null;
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ Configuration config = ctx.getConfiguration();
+ LoggerConfig loggerConfig = getLoggerConfig(ctx, loggerName);
+ assert loggerConfig != null;
+ boolean madeChanges = false;
+ if (loggerName.equals(loggerConfig.getName()) || isRootLogger(loggerName)) {
+ if (level == null || "unset".equals(level) || "null".equals(level)) {
+ level = Level.OFF.toString();
+ loggerConfig.setLevel(Level.OFF);
+ madeChanges = true;
+ } else {
+ try {
+ loggerConfig.setLevel(Level.valueOf(level));
+ madeChanges = true;
+ } catch (IllegalArgumentException iae) {
+ log.error("{} is not a valid log level! Valid values are: {}", level, getAllLevels());
+ }
+ }
+ } else {
+ //It doesn't have it's own logger yet so let's create one
+ LoggerConfig explicitConfig = new LoggerConfig(loggerName, Level.valueOf(level), true);
+ explicitConfig.setParent(loggerConfig);
+ config.addLogger(loggerName, explicitConfig);
+ madeChanges = true;
+ }
+
+ if (madeChanges) {
+ ctx.updateLoggers();
+ if (log.isInfoEnabled()) {
+ log.info("Setting log level to '{}' for logger: {}", level, loggerName);
+ }
+ }
+
+ }
+
+ protected boolean isRootLogger(String loggerName) {
+ return LoggerInfo.ROOT_NAME.equals(loggerName);
+ }
+
+ protected LoggerConfig getLoggerConfig(LoggerContext ctx, String loggerName) {
+ Configuration config = ctx.getConfiguration();
+ return isRootLogger(loggerName) ? config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME)
+ : config.getLoggerConfig(loggerName);
+ }
+
+ @Override
+ public Collection<LoggerInfo> getAllLoggers() {
+ Logger root = LogManager.getRootLogger();
+ LoggerContext ctx = (LoggerContext)LogManager.getContext(false);
+ Map<String,LoggerInfo> map = new HashMap<>(ctx.getLoggers().size());
+
+ //First let's get the explicitly configured loggers
+ Map<String, LoggerConfig> loggers = ctx.getConfiguration().getLoggers();
+ for(Map.Entry<String, LoggerConfig> logger : loggers.entrySet()) {
+ String name = logger.getKey();
+
+ if (logger == root || root.equals(logger) || isRootLogger(name) || "".equals(name)) {
+ continue;
+ }
+ map.put(name, new Log4j2Info(name, logger.getValue().getLevel()));
+ }
+
+ for (org.apache.logging.log4j.core.Logger logger : ctx.getLoggers()) {
+ String name = logger.getName();
+ if (logger == root || root.equals(logger) || isRootLogger(name))
+ continue;
+
+ map.put(name, new Log4j2Info(name, logger.getLevel()));
+ while (true) {
+ int dot = name.lastIndexOf(".");
+ if (dot < 0)
+ break;
+
+ name = name.substring(0, dot);
+ if (!map.containsKey(name))
+ map.put(name, new Log4j2Info(name, null));
+ }
+ }
+ map.put(LoggerInfo.ROOT_NAME, new Log4j2Info(LoggerInfo.ROOT_NAME, root.getLevel()));
+ return map.values();
+ }
+
+ @Override
+ public void setThreshold(String level) {
+ Log4j2Appender app = getAppender();
+ Level current = app.getThreshold();
+ app.setThreshold(Level.toLevel(level));
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ LoggerConfig config = getLoggerConfig(ctx, LoggerInfo.ROOT_NAME);
+ config.removeAppender(app.getName());
+ config.addAppender(app, app.getThreshold(), app.getFilter());
+ ((LoggerContext)LogManager.getContext(false)).updateLoggers();
+ if (log.isInfoEnabled()) {
+ log.info("Updated watcher threshold from {} to {} ", current, level);
+ }
+ }
+
+ @Override
+ public String getThreshold() {
+ return String.valueOf(getAppender().getThreshold());
+ }
+
+ protected Log4j2Appender getAppender() {
+ if (appender == null)
+ throw new IllegalStateException("No appenders configured! Must call registerListener(ListenerConfig) first.");
+ return appender;
+ }
+
+ @Override
+ public void registerListener(ListenerConfig cfg) {
+ if (history != null)
+ throw new IllegalStateException("History already registered");
+
+ history = new CircularList<LogEvent>(cfg.size);
+
+ Level threshold = (cfg.threshold != null) ? Level.toLevel(cfg.threshold) : Level.WARN;
+ ThresholdFilter filter = ThresholdFilter.createFilter(threshold, Filter.Result.ACCEPT, Filter.Result.DENY);
+
+ // If there's already an appender like this, remove it
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ LoggerConfig config = getLoggerConfig(ctx, LoggerInfo.ROOT_NAME);
+
+ appender = new Log4j2Appender(this, filter, threshold); // "Log4j2WatcherAppender"
+
+ config.removeAppender(appender.getName());
+
+ if (!appender.isStarted())
+ appender.start();
+
+ config.addAppender(appender, threshold, filter);
+ ctx.updateLoggers();
+ }
+
+ @Override
+ public long getTimestamp(LogEvent event) {
+ return event.getTimeMillis();
+ }
+
+ @Override
+ public SolrDocument toSolrDocument(LogEvent event) {
+ SolrDocument doc = new SolrDocument();
+ doc.setField("time", new Date(event.getTimeMillis()));
+ doc.setField("level", event.getLevel().toString());
+ doc.setField("logger", event.getLoggerName());
+ Message message = event.getMessage();
+ doc.setField("message", message.getFormattedMessage());
+ Throwable t = message.getThrowable();
+ if (t != null)
+ doc.setField("trace", Throwables.getStackTraceAsString(t));
+
+ Map<String,String> contextMap = event.getContextMap();
+ if (contextMap != null) {
+ for (String key : contextMap.keySet())
+ doc.setField(key, contextMap.get(key));
+ }
+
+ if (!doc.containsKey("core"))
+ doc.setField("core", ""); // avoids an ugly "undefined" column in the UI
+
+ return doc;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/logging/log4j2/package-info.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/logging/log4j2/package-info.java b/solr/core/src/java/org/apache/solr/logging/log4j2/package-info.java
new file mode 100644
index 0000000..8407984
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/logging/log4j2/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+/**
+ * LOG4J2 based implementation of {@link org.apache.solr.logging.LogWatcher}
+ */
+package org.apache.solr.logging.log4j2;
+
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index edf616e..a70e2b8 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -153,6 +153,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
SolrRequestParsers.fileCleaningTracker = new SolrFileCleaningTracker();
StartupLoggingUtils.checkLogDir();
+ log.info("Using logger factory {}", StartupLoggingUtils.getLoggerImplStr());
logWelcomeBanner();
String muteConsole = System.getProperty(SOLR_LOG_MUTECONSOLE);
if (muteConsole != null && !Arrays.asList("false","0","off","no").contains(muteConsole.toLowerCase(Locale.ROOT))) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index a768a32..784ccbe 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -4317,7 +4317,7 @@ public class SolrCLI {
* ...
* solr.log -> solr.log.1
* </pre>
- * @param generations number of generations to keep. Should agree with setting in log4j.properties
+ * @param generations number of generations to keep. Should agree with setting in log4j2.xml
* @return 0 if success
* @throws Exception if problems
*/
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
index 735cde2..7a11e15 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
@@ -16,15 +16,18 @@
*/
package org.apache.solr.util;
+import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
-import org.apache.log4j.Layout;
-import org.apache.log4j.Level;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.ThrowableInformation;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.StringUtils;
@@ -43,7 +46,18 @@ import static org.apache.solr.common.cloud.ZkStateReader.REPLICA_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
@SuppressForbidden(reason = "class is specific to log4j")
-public class SolrLogLayout extends Layout {
+@Plugin(name = "SolrLogLayout", category = "Core", elementType = "layout", printObject = true)
+public class SolrLogLayout extends AbstractStringLayout {
+
+ protected SolrLogLayout(Charset charset) {
+ super(charset);
+ }
+
+ @PluginFactory
+ public static SolrLogLayout createLayout(@PluginAttribute(value = "charset", defaultString = "UTF-8") Charset charset) {
+ return new SolrLogLayout(charset);
+ }
+
/**
* Add this interface to a thread group and the string returned by getTag()
* will appear in log statements of any threads under that group.
@@ -98,7 +112,7 @@ public class SolrLogLayout extends Layout {
public Map<String,String> classAliases = new HashMap<>();
- public void appendThread(StringBuilder sb, LoggingEvent event) {
+ public void appendThread(StringBuilder sb, LogEvent event) {
Thread th = Thread.currentThread();
/******
@@ -119,23 +133,23 @@ public class SolrLogLayout extends Layout {
}
@Override
- public String format(LoggingEvent event) {
+ public String toSerializable(LogEvent event) {
return _format(event);
}
- public String _format(LoggingEvent event) {
- String message = (String) event.getMessage();
+ public String _format(LogEvent event) {
+ String message = event.getMessage().getFormattedMessage();
if (message == null) {
message = "";
}
StringBuilder sb = new StringBuilder(message.length() + 80);
- long now = event.timeStamp;
+ long now = event.getTimeMillis();
long timeFromStart = now - startTime;
long timeSinceLast = now - lastTime;
lastTime = now;
- String shortClassName = getShortClassName(event.getLocationInformation().getClassName(),
- event.getLocationInformation().getMethodName());
+ String shortClassName = getShortClassName(event.getSource().getClassName(),
+ event.getSource().getMethodName());
/***
* sb.append(timeFromStart).append(' ').append(timeSinceLast);
@@ -212,21 +226,20 @@ public class SolrLogLayout extends Layout {
sb.append(' ');
appendMultiLineString(sb, message);
- ThrowableInformation thInfo = event.getThrowableInformation();
- if (thInfo != null) {
- Throwable th = event.getThrowableInformation().getThrowable();
- if (th != null) {
- sb.append(' ');
- String err = SolrException.toStr(th);
- String ignoredMsg = SolrException.doIgnore(th, err);
- if (ignoredMsg != null) {
- sb.append(ignoredMsg);
- } else {
- sb.append(err);
- }
+ Throwable th = event.getThrown();
+
+ if (th != null) {
+ sb.append(' ');
+ String err = SolrException.toStr(th);
+ String ignoredMsg = SolrException.doIgnore(th, err);
+ if (ignoredMsg != null) {
+ sb.append(ignoredMsg);
+ } else {
+ sb.append(err);
}
}
+
sb.append('\n');
/***
@@ -363,14 +376,6 @@ public class SolrLogLayout extends Layout {
return sb.toString() + '.' + method;
}
- @Override
- public void activateOptions() {}
-
- @Override
- public boolean ignoresThrowable() {
- return false;
- }
-
private void appendMDC(StringBuilder sb) {
if (!StringUtils.isEmpty(MDC.get(NODE_NAME_PROP))) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
----------------------------------------------------------------------
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 c582eff..7dded81 100644
--- a/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
@@ -18,12 +18,15 @@
package org.apache.solr.util;
import java.lang.invoke.MethodHandles;
-import java.util.Enumeration;
+import java.util.Map;
-import org.apache.log4j.Appender;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.ConsoleAppender;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.solr.common.util.SuppressForbidden;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,6 +52,10 @@ public final class StartupLoggingUtils {
}
}
+ public static String getLoggerImplStr() {
+ return binder.getLoggerFactoryClassStr();
+ }
+
/**
* Disables all log4j ConsoleAppender's by modifying log4j configuration dynamically.
* Must only be used during early startup
@@ -61,15 +68,16 @@ public final class StartupLoggingUtils {
logNotSupported("Could not mute logging to console.");
return false;
}
- org.apache.log4j.Logger rootLogger = LogManager.getRootLogger();
- Enumeration appenders = rootLogger.getAllAppenders();
- while (appenders.hasMoreElements()) {
- Appender appender = (Appender) appenders.nextElement();
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ Configuration config = ctx.getConfiguration();
+ LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
+ Map<String, Appender> appenders = loggerConfig.getAppenders();
+ appenders.forEach((name, appender) -> {
if (appender instanceof ConsoleAppender) {
- log.info("Property solr.log.muteconsole given. Muting ConsoleAppender named " + appender.getName());
- rootLogger.removeAppender(appender);
+ loggerConfig.removeAppender(name);
+ ctx.updateLoggers();
}
- }
+ });
return true;
} catch (Exception e) {
logNotSupported("Could not mute logging to console.");
@@ -89,7 +97,12 @@ public final class StartupLoggingUtils {
logNotSupported("Could not change log level.");
return false;
}
- LogManager.getRootLogger().setLevel(Level.toLevel(logLevel, Level.INFO));
+
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ Configuration config = ctx.getConfiguration();
+ LoggerConfig loggerConfig = config.getRootLogger();
+ loggerConfig.setLevel(Level.toLevel(logLevel, Level.INFO));
+ ctx.updateLoggers();
return true;
} catch (Exception e) {
logNotSupported("Could not change log level.");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/test-files/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/log4j.properties b/solr/core/src/test-files/log4j.properties
deleted file mode 100644
index 969439a..0000000
--- a/solr/core/src/test-files/log4j.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-# Logging level
-log4j.rootLogger=INFO, CONSOLE
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.err
-log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p (%t) [%X{node_name} %X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
-log4j.logger.org.apache.zookeeper=WARN
-log4j.logger.org.apache.hadoop=WARN
-log4j.logger.org.apache.directory=WARN
-log4j.logger.org.apache.solr.hadoop=INFO
-
-#log4j.logger.org.apache.solr.update.processor.LogUpdateProcessorFactory=DEBUG
-#log4j.logger.org.apache.solr.update.processor.DistributedUpdateProcessor=DEBUG
-#log4j.logger.org.apache.solr.update.PeerSync=DEBUG
-#log4j.logger.org.apache.solr.core.CoreContainer=DEBUG
-#log4j.logger.org.apache.solr.cloud.RecoveryStrategy=DEBUG
-#log4j.logger.org.apache.solr.cloud.SyncStrategy=DEBUG
-#log4j.logger.org.apache.solr.handler.admin.CoreAdminHandler=DEBUG
-#log4j.logger.org.apache.solr.cloud.ZkController=DEBUG
-#log4j.logger.org.apache.solr.update.DefaultSolrCoreState=DEBUG
-#log4j.logger.org.apache.solr.common.cloud.ConnectionManager=DEBUG
-#log4j.logger.org.apache.solr.update.UpdateLog=DEBUG
-#log4j.logger.org.apache.solr.cloud.ChaosMonkey=DEBUG
-#log4j.logger.org.apache.solr.update.TransactionLog=DEBUG
-#log4j.logger.org.apache.solr.handler.ReplicationHandler=DEBUG
-#log4j.logger.org.apache.solr.handler.IndexFetcher=DEBUG
-
-#log4j.logger.org.apache.solr.common.cloud.ClusterStateUtil=DEBUG
-#log4j.logger.org.apache.solr.cloud.OverseerAutoReplicaFailoverThread=DEBUG
-
-#log4j.logger.org.apache.http.wire=DEBUG
-#log4j.logger.org.apache.http.headers=DEBUG
-#log4j.logger.org.apache.http.impl.conn.PoolingHttpClientConnectionManager=DEBUG
-#log4j.logger.org.apache.http.impl.conn.BasicClientConnectionManager=DEBUG
-#log4j.logger.org.apache.http=DEBUG
-#log4j.logger.org.apache.solr.client.solrj.impl.SolrHttpRequestRetryHandler=DEBUG
-#log4j.logger.org.eclipse.jetty=DEBUG
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/test-files/log4j2.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/log4j2.xml b/solr/core/src/test-files/log4j2.xml
new file mode 100644
index 0000000..7d0ebf7
--- /dev/null
+++ b/solr/core/src/test-files/log4j2.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %-4r %-5p (%t) [%X{node_name} %X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+ <Logger name="org.apache.hadoop" level="WARN"/>
+ <Logger name="org.apache.directory" level="WARN"/>
+ <Logger name="org.apache.solr.hadoop" level="INFO"/>
+
+ <Root level="INFO">
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/624d128b/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java b/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
index 4c780cc..af37940 100644
--- a/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
@@ -20,11 +20,14 @@ import java.io.StringWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.apache.log4j.WriterAppender;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.WriterAppender;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.layout.PatternLayout;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.SuppressForbidden;
import org.apache.solr.core.SolrCore;
@@ -44,26 +47,40 @@ public class RequestLoggingTest extends SolrTestCaseJ4 {
@Before
public void setupAppender() {
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ LoggerConfig config = ctx.getConfiguration().getLoggerConfig("RequestLoggingTest");
+
writer = new StringWriter();
- appender = new WriterAppender(new SimpleLayout(), writer);
+ appender = WriterAppender.createAppender(
+ PatternLayout
+ .newBuilder()
+ .withPattern("%-5p [%t]: %m%n")
+ .build(),
+ null, writer, "RequestLoggingTest", false, true);
+ appender.start();
+
}
@Test
public void testLogBeforeExecuteWithCoreLogger() {
- Logger logger = Logger.getLogger(SolrCore.class);
+ Logger logger = LogManager.getLogger(SolrCore.class);
testLogBeforeExecute(logger);
}
@Test
public void testLogBeforeExecuteWithRequestLogger() {
- Logger logger = Logger.getLogger("org.apache.solr.core.SolrCore.Request");
+ Logger logger = LogManager.getLogger("org.apache.solr.core.SolrCore.Request");
testLogBeforeExecute(logger);
}
public void testLogBeforeExecute(Logger logger) {
Level level = logger.getLevel();
- logger.setLevel(Level.DEBUG);
- logger.addAppender(appender);
+
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ LoggerConfig config = ctx.getConfiguration().getLoggerConfig(logger.getName());
+ config.setLevel(Level.DEBUG);
+ config.addAppender(appender, Level.DEBUG, null);
+ ctx.updateLoggers();
try {
assertQ(req("q", "*:*"));
@@ -77,8 +94,9 @@ public class RequestLoggingTest extends SolrTestCaseJ4 {
assertFalse(msg, group.contains("status"));
assertFalse(msg, group.contains("QTime"));
} finally {
- logger.setLevel(level);
- logger.removeAppender(appender);
+ config.setLevel(level);
+ config.removeAppender(appender.getName());
+ ctx.updateLoggers();
}
}
}