You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by va...@apache.org on 2018/03/26 23:25:49 UTC

lucene-solr:branch_7x: SOLR-7887: Log4J2 upgrade fixes part 2

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 890dcb7d9 -> 003be2da4


SOLR-7887: Log4J2 upgrade fixes part 2

(cherry picked from commit bd42934)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/003be2da
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/003be2da
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/003be2da

Branch: refs/heads/branch_7x
Commit: 003be2da436f82abc0758e8aa0c69ec9e5fdc417
Parents: 890dcb7
Author: Varun Thacker <va...@apache.org>
Authored: Mon Mar 26 15:48:01 2018 -0700
Committer: Varun Thacker <va...@apache.org>
Committed: Mon Mar 26 16:20:04 2018 -0700

----------------------------------------------------------------------
 lucene/ivy-versions.properties                  |  6 +--
 solr/CHANGES.txt                                |  4 +-
 .../prometheus-exporter/conf/log4j.properties   | 22 --------
 .../contrib/prometheus-exporter/conf/log4j2.xml | 53 ++++++++++++++++++++
 .../src/test-files/conf/log4j.properties        | 22 --------
 .../src/test-files/conf/log4j2.xml              | 35 +++++++++++++
 solr/solr-ref-guide/src/_config.yml.template    |  2 +-
 .../solr-ref-guide/src/configuring-logging.adoc |  6 +--
 8 files changed, 96 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/lucene/ivy-versions.properties
----------------------------------------------------------------------
diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index edd6135..95ede15 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -84,11 +84,6 @@ io.prometheus.version = 0.2.0
 /joda-time/joda-time = 2.2
 /junit/junit = 4.10
 
-# NOTE: split out from the full version to also use as solr-ref-guide attribute
-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
 /net.arnx/jsonic = 1.2.7
@@ -182,6 +177,7 @@ 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.version = 2.11.0
 /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}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0d022da..da95c08 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -32,7 +32,9 @@ Jetty 9.4.8.v20171121
 Upgrade Notes
 ----------------------
 
-* SOLR-7887: Solr now uses Log4J 2.11. The log4j configuration is now in log4j2.xml rather than lo4j.properties files
+* SOLR-7887: Solr now uses Log4J 2.11 . The log4j configuration is now in log4j2.xml rather than log4j.properties files.
+  This is a server side change only and clients using SolrJ won't need any changes. Clients can still use any logging
+  implementation which is compatible with SLF4J.
 
 New Features
 ----------------------

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/contrib/prometheus-exporter/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/conf/log4j.properties b/solr/contrib/prometheus-exporter/conf/log4j.properties
deleted file mode 100644
index 5dd6899..0000000
--- a/solr/contrib/prometheus-exporter/conf/log4j.properties
+++ /dev/null
@@ -1,22 +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.rootLogger=INFO, stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5p [%c] - %m%n

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/contrib/prometheus-exporter/conf/log4j2.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/conf/log4j2.xml b/solr/contrib/prometheus-exporter/conf/log4j2.xml
new file mode 100644
index 0000000..434c976
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/conf/log4j2.xml
@@ -0,0 +1,53 @@
+<?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="STDOUT" target="SYSTEM_OUT">
+      <PatternLayout>
+        <Pattern>
+          %d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
+        </Pattern>
+      </PatternLayout>
+    </Console>
+    <RollingFile
+        name="RollingFile"
+        fileName="${sys:solr.log.dir}/solr.log"
+        filePattern="${sys:solr.log.dir}/solr.%i.log" >
+      <PatternLayout>
+        <Pattern>
+          %d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
+        </Pattern>
+      </PatternLayout>
+      <Policies>
+        <SizeBasedTriggeringPolicy size="32 MB"/>
+      </Policies>
+      <DefaultRolloverStrategy max="10"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.hadoop" level="warn"/>
+    <Logger name="org.apache.solr.update.LoggingInfoStream" level="off"/>
+    <Logger name="org.apache.zookeeper" level="warn"/>
+
+    <Root level="info">
+      <AppenderRef ref="RollingFile"/>
+      <AppenderRef ref="STDOUT"/>
+    </Root>
+  </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/contrib/prometheus-exporter/src/test-files/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/src/test-files/conf/log4j.properties b/solr/contrib/prometheus-exporter/src/test-files/conf/log4j.properties
deleted file mode 100644
index 5dd6899..0000000
--- a/solr/contrib/prometheus-exporter/src/test-files/conf/log4j.properties
+++ /dev/null
@@ -1,22 +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.rootLogger=INFO, stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5p [%c] - %m%n

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/contrib/prometheus-exporter/src/test-files/conf/log4j2.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/src/test-files/conf/log4j2.xml b/solr/contrib/prometheus-exporter/src/test-files/conf/log4j2.xml
new file mode 100644
index 0000000..5b31a73
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/src/test-files/conf/log4j2.xml
@@ -0,0 +1,35 @@
+<?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>
+          %d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5p [%c] - %m%n
+        </Pattern>
+      </PatternLayout>
+    </Console>
+  </Appenders>
+
+  <Loggers>
+    <Root level="INFO">
+      <AppenderRef ref="STDERR"/>
+    </Root>
+  </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/solr-ref-guide/src/_config.yml.template
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/_config.yml.template b/solr/solr-ref-guide/src/_config.yml.template
index 41d25f4..23c6b5c 100755
--- a/solr/solr-ref-guide/src/_config.yml.template
+++ b/solr/solr-ref-guide/src/_config.yml.template
@@ -80,7 +80,7 @@ solr-attributes: &solr-attributes-ref
   build-year: "${current.year}"
   ivy-commons-codec-version: "${ivyversions./commons-codec/commons-codec}"
   ivy-dropwizard-version: "${ivyversions.io.dropwizard.metrics.version}"
-  ivy-log4j-version: "${ivyversions.org.log4j.major.version}"
+  ivy-log4j-version: "${ivyversions.org.apache.logging.log4j.version}"
   ivy-opennlp-version: "${ivyversions./org.apache.opennlp/opennlp-tools}"
   ivy-tika-version: "${ivyversions.org.apache.tika.version}"
   ivy-velocity-tools-version: "${ivyversions./org.apache.velocity/velocity-tools}"

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/003be2da/solr/solr-ref-guide/src/configuring-logging.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/configuring-logging.adoc b/solr/solr-ref-guide/src/configuring-logging.adoc
index af8db27..c6a3ad0 100644
--- a/solr/solr-ref-guide/src/configuring-logging.adoc
+++ b/solr/solr-ref-guide/src/configuring-logging.adoc
@@ -84,7 +84,7 @@ bin/solr start -f -q
 
 == Permanent Logging Settings
 
-Solr uses http://logging.apache.org/log4j/{ivy-log4j-version}/[Log4J version {ivy-log4j-version}] for logging which is configured using `server/resources/log4j2.xml`. Take a moment to inspect the contents of the `log4j2.xml` file so that you are familiar with its structure. By default, Solr log messages will be written to `SOLR_LOGS_DIR/solr.log`.
+Solr uses http://logging.apache.org/log4j/log4j-{ivy-log4j-version}/[Log4J version {ivy-log4j-version}] for logging which is configured using `server/resources/log4j2.xml`. Take a moment to inspect the contents of the `log4j2.xml` file so that you are familiar with its structure. By default, Solr log messages will be written to `SOLR_LOGS_DIR/solr.log`.
 
 When you're ready to deploy Solr in production, set the variable `SOLR_LOGS_DIR` to the location where you want Solr to write log files, such as `/var/solr/logs`. You may also want to tweak `log4j2.xml`. Note that if you installed Solr as a service using the instructions provided in <<taking-solr-to-production.adoc#taking-solr-to-production,Taking Solr to Production>>, then see `/var/solr/log4j2.xml` instead of the default `server/resources` version.
 
@@ -94,12 +94,12 @@ Also, in `log4j2.xml` if the default log rotation size threshold of 32MB is too
 
 [source,text]
 ----
-log4j.appender.file.MaxFileSize=100MB
+<SizeBasedTriggeringPolicy size="100 MB"/>
 ----
 
 Java Garbage Collection logs are rotated by the JVM when size hits 20M, for a max of 9 generations. Old GC logs are moved to `SOLR_LOGS_DIR/archived`. These settings can only be changed by editing the start scripts.
 
-On every startup of Solr, the start script will clean up old logs and rotate the main `solr.log` file. If you changed the `log4j.appender.file.MaxBackupIndex` setting in `log4j2.xml`, you also need to change the corresponding setting `-rotate_solr_logs 10` in the start script.
+On every startup of Solr, the start script will clean up old logs and rotate the main `solr.log` file. If you changed the `<DefaultRolloverStrategy max="10"/>` setting in `log4j2.xml`, you also need to change the corresponding setting `-rotate_solr_logs 10` in the start script.
 
 You can disable the automatic log rotation at startup by changing the setting `SOLR_LOG_PRESTART_ROTATION` found in `bin/solr.in.sh` or `bin/solr.in.cmd` to false.