You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2023/11/13 06:51:10 UTC

(phoenix-queryserver) branch master updated: PHOENIX-7091 Cleanup and ban log4j and related jars from phoenix-query-server

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

stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-queryserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f0c2860  PHOENIX-7091 Cleanup and ban log4j and related jars from phoenix-query-server
f0c2860 is described below

commit f0c2860fea7fe2704f11476d457cd0d38ddd345d
Author: Jain, Nihal <ni...@gmail.com>
AuthorDate: Tue Oct 31 19:06:46 2023 +0530

    PHOENIX-7091 Cleanup and ban log4j and related jars from phoenix-query-server
    
    - Add maven-enforcer-plugin and use it to ban commons-logging and other logging framework related jars
    - Remove all traces of log4j:log4j, org.slf4j:slf4j-log4j12 and commons-logging:commons-logging from dependency list
    - Replace log4j.properties with log4j2.properties (copied from hbase project)
    - Fix issue where IT logs where not getting logged in surefire reports due to "Failed to load class "org.slf4j.impl.StaticLoggerBinder"
     - See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    - Fix log4j duplicate dependency warning in pom.xml
---
 phoenix-queryserver-it/pom.xml                     |  10 ++
 .../src/it/resources/log4j.properties              |  71 ---------
 .../src/it/resources/log4j2.properties             | 137 ++++++++++++++++
 pom.xml                                            | 176 +++++++++++++++++++--
 4 files changed, 312 insertions(+), 82 deletions(-)

diff --git a/phoenix-queryserver-it/pom.xml b/phoenix-queryserver-it/pom.xml
index 36b9d5c..0dcd5c9 100644
--- a/phoenix-queryserver-it/pom.xml
+++ b/phoenix-queryserver-it/pom.xml
@@ -202,5 +202,15 @@
         <artifactId>log4j-core</artifactId>
         <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>
diff --git a/phoenix-queryserver-it/src/it/resources/log4j.properties b/phoenix-queryserver-it/src/it/resources/log4j.properties
deleted file mode 100644
index 06af7bc..0000000
--- a/phoenix-queryserver-it/src/it/resources/log4j.properties
+++ /dev/null
@@ -1,71 +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.
-
-# Define some default values that can be overridden by system properties
-hbase.root.logger=DEBUG,console
-hbase.log.dir=.
-hbase.log.file=hbase.log
-
-# Define the root logger to the system property "hbase.root.logger".
-log4j.rootLogger=${hbase.root.logger}
-
-# Logging Threshold
-log4j.threshhold=ALL
-
-#
-# Daily Rolling File Appender
-#
-log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.DRFA.File=${hbase.log.dir}/${hbase.log.file}
-
-# Rollver at midnight
-log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
-
-# 30-day backup
-#log4j.appender.DRFA.MaxBackupIndex=30
-log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout
-
-# Pattern format: Date LogLevel LoggerName LogMessage
-#log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
-
-# Debugging Pattern format
-log4j.appender.DRFA.layout.ConversionPattern=%d %-5p [%t] %C{2}(%L): %m%n
-
-
-#
-# console
-# Add "console" to rootlogger above if you want to use this
-#
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.target=System.err
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d %-5p [%t] %C{2}(%L): %m%n
-
-# Custom Logging levels
-
-#log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG
-
-log4j.logger.org.apache.zookeeper=ERROR
-
-# Suppresses junk from minikdc
-log4j.logger.org.mortbay.log=WARN
-log4j.logger.org.apache.directory=WARN
-log4j.logger.net.sf.ehcache=WARN
-# Suppress the "no group for user" spamming
-log4j.logger.org.apache.hadoop.security.UserGroupInformation=ERROR
-log4j.logger.org.apache.hadoop.hdfs=INFO
-log4j.logger.org.apache.hadoop.metrics2=INFO
-log4j.logger.org.apache.hadoop.ipc=INFO
diff --git a/phoenix-queryserver-it/src/it/resources/log4j2.properties b/phoenix-queryserver-it/src/it/resources/log4j2.properties
new file mode 100644
index 0000000..2659468
--- /dev/null
+++ b/phoenix-queryserver-it/src/it/resources/log4j2.properties
@@ -0,0 +1,137 @@
+#/**
+# * 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.
+# */
+
+status = warn
+dest = err
+name = PropertiesConfig
+
+# Console appender
+appender.console.type = Console
+appender.console.target = SYSTEM_ERR
+appender.console.name = console
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %d{ISO8601} %-5p [%t%notEmpty{ %X}] %c{2}: %.1000m%n
+
+# Daily Rolling File Appender
+appender.DRFA.type = RollingFile
+appender.DRFA.name = DRFA
+appender.DRFA.fileName = ${sys:hbase.log.dir:-.}/${sys:hbase.log.file:-hbase.log}
+appender.DRFA.filePattern = ${sys:hbase.log.dir:-.}/${sys:hbase.log.file:-hbase.log}.%d{yyyy-MM-dd}
+appender.DRFA.createOnDemand = true
+appender.DRFA.layout.type = PatternLayout
+appender.DRFA.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %.1000m%n
+appender.DRFA.policies.type = Policies
+appender.DRFA.policies.time.type = TimeBasedTriggeringPolicy
+appender.DRFA.policies.time.interval = 1
+appender.DRFA.policies.time.modulate = true
+appender.DRFA.policies.size.type = SizeBasedTriggeringPolicy
+appender.DRFA.policies.size.size = ${sys:hbase.log.maxfilesize:-256MB}
+appender.DRFA.strategy.type = DefaultRolloverStrategy
+appender.DRFA.strategy.max = ${sys:hbase.log.maxbackupindex:-20}
+
+# Rolling File Appender
+appender.RFA.type = RollingFile
+appender.RFA.name = RFA
+appender.RFA.fileName = ${sys:hbase.log.dir:-.}/${sys:hbase.log.file:-hbase.log}
+appender.RFA.filePattern = ${sys:hbase.log.dir:-.}/${sys:hbase.log.file:-hbase.log}.%i
+appender.RFA.createOnDemand = true
+appender.RFA.layout.type = PatternLayout
+appender.RFA.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %.1000m%n
+appender.RFA.policies.type = Policies
+appender.RFA.policies.size.type = SizeBasedTriggeringPolicy
+appender.RFA.policies.size.size = ${sys:hbase.log.maxfilesize:-256MB}
+appender.RFA.strategy.type = DefaultRolloverStrategy
+appender.RFA.strategy.max = ${sys:hbase.log.maxbackupindex:-20}
+
+# Security Audit Appender
+appender.RFAS.type = RollingFile
+appender.RFAS.name = RFAS
+appender.RFAS.fileName = ${sys:hbase.log.dir:-.}/${sys:hbase.security.log.file:-SecurityAuth.audit}
+appender.RFAS.filePattern = ${sys:hbase.log.dir:-.}/${sys:hbase.security.log.file:-SecurityAuth.audit}.%i
+appender.RFAS.createOnDemand = true
+appender.RFAS.layout.type = PatternLayout
+appender.RFAS.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %.1000m%n
+appender.RFAS.policies.type = Policies
+appender.RFAS.policies.size.type = SizeBasedTriggeringPolicy
+appender.RFAS.policies.size.size = ${sys:hbase.security.log.maxfilesize:-256MB}
+appender.RFAS.strategy.type = DefaultRolloverStrategy
+appender.RFAS.strategy.max = ${sys:hbase.security.log.maxbackupindex:-20}
+
+# Http Access Log RFA, uncomment this if you want an http access.log
+# appender.AccessRFA.type = RollingFile
+# appender.AccessRFA.name = AccessRFA
+# appender.AccessRFA.fileName = /var/log/hbase/access.log
+# appender.AccessRFA.filePattern = /var/log/hbase/access.log.%i
+# appender.AccessRFA.createOnDemand = true
+# appender.AccessRFA.layout.type = PatternLayout
+# appender.AccessRFA.layout.pattern = %m%n
+# appender.AccessRFA.policies.type = Policies
+# appender.AccessRFA.policies.size.type = SizeBasedTriggeringPolicy
+# appender.AccessRFA.policies.size.size = 200MB
+# appender.AccessRFA.strategy.type = DefaultRolloverStrategy
+# appender.AccessRFA.strategy.max = 10
+
+# Null Appender
+appender.NullAppender.type = Null
+appender.NullAppender.name = NullAppender
+
+rootLogger = ${sys:hbase.root.logger:-INFO,console}
+
+logger.SecurityLogger.name = SecurityLogger
+logger.SecurityLogger = ${sys:hbase.security.logger:-INFO,console}
+logger.SecurityLogger.additivity = false
+
+# Custom Logging levels
+# logger.zookeeper.name = org.apache.zookeeper
+# logger.zookeeper.level = ERROR
+
+# logger.FSNamesystem.name = org.apache.hadoop.fs.FSNamesystem
+# logger.FSNamesystem.level = DEBUG
+
+# logger.hbase.name = org.apache.hadoop.hbase
+# logger.hbase.level = DEBUG
+
+# logger.META.name = org.apache.hadoop.hbase.META
+# logger.META.level = DEBUG
+
+# Make these two classes below DEBUG to see more zk debug.
+# logger.ZKUtil.name = org.apache.hadoop.hbase.zookeeper.ZKUtil
+# logger.ZKUtil.level = DEBUG
+
+# logger.ZKWatcher.name = org.apache.hadoop.hbase.zookeeper.ZKWatcher
+# logger.ZKWatcher.level = DEBUG
+
+# logger.dfs.name = org.apache.hadoop.dfs
+# logger.dfs.level = DEBUG
+
+# Prevent metrics subsystem start/stop messages (HBASE-17722)
+logger.MetricsConfig.name = org.apache.hadoop.metrics2.impl.MetricsConfig
+logger.MetricsConfig.level = WARN
+
+logger.MetricsSinkAdapte.name = org.apache.hadoop.metrics2.impl.MetricsSinkAdapter
+logger.MetricsSinkAdapte.level = WARN
+
+logger.MetricsSystemImpl.name = org.apache.hadoop.metrics2.impl.MetricsSystemImpl
+logger.MetricsSystemImpl.level = WARN
+
+# Disable request log by default, you can enable this by changing the appender
+logger.http.name = http.requests
+logger.http.additivity = false
+logger.http = INFO,NullAppender
+# Replace the above with this configuration if you want an http access.log
+# logger.http = INFO,AccessRFA
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c203f5f..33fadfb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -370,6 +370,49 @@
                         </excludes>
                     </configuration>
                 </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-enforcer-plugin</artifactId>
+                    <executions>
+                        <execution>
+                            <id>banned-commons-logging</id>
+                            <goals>
+                                <goal>enforce</goal>
+                            </goals>
+                            <configuration>
+                                <rules>
+                                    <bannedDependencies>
+                                        <excludes>
+                                            <exclude>commons-logging:commons-logging</exclude>
+                                        </excludes>
+                                        <message>We don't use commons-logging any more, so do not depend on it directly.</message>
+                                        <searchTransitive>false</searchTransitive>
+                                    </bannedDependencies>
+                                </rules>
+                            </configuration>
+                        </execution>
+                        <execution>
+                            <id>banned-other-logging-framework</id>
+                            <goals>
+                                <goal>enforce</goal>
+                            </goals>
+                            <configuration>
+                                <rules>
+                                    <bannedDependencies>
+                                        <excludes>
+                                            <exclude>log4j:*</exclude>
+                                            <exclude>org.slf4j:slf4j-log4j12</exclude>
+                                            <exclude>ch.qos.reload4j:*</exclude>
+                                            <exclude>org.slf4j:slf4j-reload4j</exclude>
+                                            <exclude>ch.qos.logback:*</exclude>
+                                        </excludes>
+                                        <message>We do not allow other logging frameworks as now we use log4j2</message>
+                                    </bannedDependencies>
+                                </rules>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
             </plugins>
         </pluginManagement>
 
@@ -461,6 +504,18 @@
                         <groupId>org.jruby</groupId>
                         <artifactId>jruby-complete</artifactId>
                     </exclusion>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
                 </exclusions>
             </dependency>
             <dependency>
@@ -484,12 +539,34 @@
                         <groupId>javax.servlet</groupId>
                         <artifactId>servlet-api</artifactId>
                     </exclusion>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
                 </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-auth</artifactId>
                 <version>${hadoop.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
 
             <!-- General Dependencies -->
@@ -527,6 +604,10 @@
                     <groupId>org.slf4j</groupId>
                     <artifactId>slf4j-log4j12</artifactId>
                   </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
                 </exclusions>
             </dependency>
             <dependency>
@@ -602,12 +683,13 @@
                 <artifactId>argparse4j</artifactId>
                 <version>0.8.1</version>
             </dependency>
+
+           <!-- Logging backends -->
             <dependency>
                 <groupId>org.slf4j</groupId>
                 <artifactId>slf4j-api</artifactId>
                 <version>${slf4j.version}</version>
             </dependency>
-           <!-- Logging backends -->
             <dependency>
                 <groupId>org.apache.logging.log4j</groupId>
                 <artifactId>log4j-api</artifactId>
@@ -727,6 +809,12 @@
                 <artifactId>hadoop-hdfs</artifactId>
                 <version>${hadoop.version}</version>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
@@ -734,6 +822,16 @@
                 <version>${hadoop.version}</version>
                 <type>test-jar</type>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
@@ -741,30 +839,76 @@
                 <version>${hadoop.version}</version>
                 <type>test-jar</type>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-yarn-api</artifactId>
                 <version>${hadoop.version}</version>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-mapreduce-client-core</artifactId>
                 <version>${hadoop.version}</version>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-yarn-client</artifactId>
                 <version>${hadoop.version}</version>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-yarn-common</artifactId>
                 <version>${hadoop.version}</version>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
@@ -785,6 +929,20 @@
                 <version>${phoenix.version}</version>
                 <classifier>tests</classifier>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>org.apache.phoenix</groupId>
@@ -815,6 +973,12 @@
                 <artifactId>hadoop-minikdc</artifactId>
                 <version>${hadoop.version}</version>
                 <scope>test</scope>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>bouncycastle</groupId>
@@ -822,16 +986,6 @@
                 <version>140</version>
                 <scope>test</scope>
             </dependency>
-            <dependency>
-                <groupId>org.apache.logging.log4j</groupId>
-                <artifactId>log4j-api</artifactId>
-                <version>${log4j2.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.logging.log4j</groupId>
-                <artifactId>log4j-core</artifactId>
-                <version>${log4j2.version}</version>
-            </dependency>
         </dependencies>
     </dependencyManagement>
   <profiles>