Skip to content

Commit

Permalink
PHOENIX-6931 Switch queryserver to log4j2
Browse files Browse the repository at this point in the history
  • Loading branch information
stoty committed May 2, 2023
1 parent 4e1ab1f commit 22885c6
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 110 deletions.
76 changes: 0 additions & 76 deletions bin/log4j.properties

This file was deleted.

78 changes: 78 additions & 0 deletions bin/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#/**
# * 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.
# */

# This config is used by sqlline, pherf and psql

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] %c{2}: %.1000m%n

# Not used by default
# Daily Rolling File Appender
appender.DRFA.type = RollingFile
appender.DRFA.name = DRFA
appender.DRFA.fileName = ${sys:psql.log.dir:-.}/${sys:psql.log.file:-psql.log}
appender.DRFA.filePattern = ${sys:psql.log.dir:-.}/${sys:psql.log.file:-psql.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:psql.log.maxfilesize:-256MB}
appender.DRFA.strategy.type = DefaultRolloverStrategy
appender.DRFA.strategy.max = ${sys:psql.log.maxbackupindex:-20}

# Null Appender
appender.NullAppender.type = Null
appender.NullAppender.name = NullAppender

rootLogger = ${sys:psql.root.logger:-WARN,console}

# Custom Logging levels
logger.zookeeper.name = org.apache.zookeeper
logger.zookeeper.level = ERROR

logger.hbase_zk_rzk.name = org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper
logger.hbase_zk_rzk.level = ERROR

logger.hbase_zk_zku.name = org.apache.hadoop.hbase.zookeeper.ZKUtil
logger.hbase_zk_zku.level = ERROR

logger.hbase_conf.name = org.apache.hadoop.hbase.HBaseConfiguration
logger.hbase_conf.level = ERROR


# query server custom logging levels
logger.calcite_avatica.name = org.apache.calcite.avatica
logger.calcite_avatica.level = INFO

logger.phoenix_queryserver_server.name = org.apache.phoenix.queryserver.server
logger.phoenix_queryserver_server.level = INFO

logger.eclipse_jetty.name = org.eclipse.jetty.server
logger.eclipse_jetty.level = INFO
8 changes: 6 additions & 2 deletions bin/phoenix_queryserver_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ def setPath():
PHOENIX_QUERYSERVER_JAR_PATTERN = "phoenix-queryserver-[!c]*.jar"
PHOENIX_LOADBALANCER_JAR_PATTERN = "load-balancer-*[!t][!e][!s][!t][!s].jar"
SQLLINE_WITH_DEPS_PATTERN = "sqlline-*-jar-with-dependencies.jar"
SLF4J_BACKEND_JAR_PATTERN = "slf4j-reload4j-*[!s].jar"
LOGGING_JAR_PATTERN = "reload4j-*[!s].jar"
SLF4J_BACKEND_JAR_PATTERN = "log4j-slf4j*.jar"
LOGGING_JAR_PATTERN = "log4j-core*.jar"
LOGGING_JAR_PATTERN2 = "log4j-api*.jar"
LOGGING_JAR_PATTERN3 = "log4j-1.2-api*.jar"

OVERRIDE_SLF4J_BACKEND = "PHOENIX_THIN_OVERRIDE_SLF4J_BACKEND"
OVERRIDE_LOGGING = "OVERRIDE_LOGGING_JAR_LOCATION"
Expand Down Expand Up @@ -167,6 +169,8 @@ def setPath():
logging_jar = os.environ.get(OVERRIDE_LOGGING)
if logging_jar is None or logging_jar == "":
logging_jar = findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN, os.path.join(current_dir, "..","lib"))
logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN2, os.path.join(current_dir, "..","lib"))
logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN3, os.path.join(current_dir, "..","lib"))

return ""

Expand Down
2 changes: 1 addition & 1 deletion bin/queryserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
phoenix_queryserver_utils.phoenix_client_jar + os.pathsep + \
phoenix_queryserver_utils.phoenix_queryserver_jar + \
" -Dproc_phoenixserver" + \
" -Dlog4j.configuration=file:" + os.path.join(phoenix_queryserver_utils.current_dir, "log4j.properties") + \
' -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_queryserver_utils.current_dir, "log4j2.properties") + \
" -Dpsql.root.logger=%(root_logger)s" + \
" -Dpsql.log.dir=%(log_dir)s" + \
" -Dpsql.log.file=%(log_file)s" + \
Expand Down
3 changes: 1 addition & 2 deletions bin/sqlline-thin.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ def get_spnego_auth_disabled():
phoenix_queryserver_utils.phoenix_thin_client_jar + os.pathsep + \
phoenix_queryserver_utils.slf4j_backend_jar + os.pathsep + \
phoenix_queryserver_utils.logging_jar +\
'" -Dlog4j.configuration=file:' + \
os.path.join(phoenix_queryserver_utils.current_dir, "log4j.properties") + \
'" -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_queryserver_utils.current_dir, "log4j2.properties") + \
' -Djavax.security.auth.useSubjectCredsOnly=false ' + \
disable_jna + \
" org.apache.phoenix.queryserver.client.SqllineWrapper -d org.apache.phoenix.queryserver.client.Driver " + \
Expand Down
16 changes: 12 additions & 4 deletions phoenix-queryserver-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@
<classifier>jar-with-dependencies</classifier>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>
</dependencies>

Expand Down
18 changes: 4 additions & 14 deletions phoenix-queryserver-assembly/src/assembly/cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<outputDirectory>phoenix-queryserver-${project.parent.version}/lib</outputDirectory>
<includes>
<include>sqlline:sqlline:jar:jar-with-dependencies</include>
<include>org.apache.logging.log4j:log4j-slf4j-impl</include>
<include>org.apache.logging.log4j:log4j-api</include>
<include>org.apache.logging.log4j:log4j-core</include>
<include>org.apache.logging.log4j:log4j-1.2-api</include>
</includes>
</dependencySet>
<dependencySet>
Expand All @@ -68,19 +72,5 @@
<include>org.apache.phoenix:${phoenix.client.artifactid}:jar</include>
</includes>
</dependencySet>
<dependencySet>
<unpack>false</unpack>
<outputDirectory>phoenix-queryserver-${project.parent.version}/lib</outputDirectory>
<includes>
<include>org.slf4j:slf4j-reload4j</include>
</includes>
</dependencySet>
<dependencySet>
<unpack>false</unpack>
<outputDirectory>phoenix-queryserver-${project.parent.version}/lib</outputDirectory>
<includes>
<include>ch.qos.reload4j:reload4j</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
32 changes: 21 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@
<commons-collections.version>3.2.2</commons-collections.version>
<sqlline.version>1.9.0</sqlline.version>
<slf4j.version>1.7.36</slf4j.version>
<reload4j.version>1.2.19</reload4j.version>
<avatica.version>1.23.0</avatica.version>
<servlet.api.version>3.1.0</servlet.api.version>
<jsr305.version>3.0.0</jsr305.version>
<log4j2.version>2.19.0</log4j2.version>
<log4j2.version>2.20.0</log4j2.version>

<!-- Test Dependency versions -->
<mockito-all.version>1.8.5</mockito-all.version>
Expand Down Expand Up @@ -562,25 +561,36 @@
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.api.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
<artifactId>argparse4j</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Logging backends -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<version>${slf4j.version}</version>
<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>
<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
<version>${reload4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
<artifactId>argparse4j</artifactId>
<version>0.8.1</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j2.version}</version>
</dependency>

<!-- Phoenix test dependencies -->
Expand Down

0 comments on commit 22885c6

Please sign in to comment.