Skip to content

Commit 3b6035d

Browse files
committed
HBASE-26802 Backport the log4j2 changes to branch-2
1 parent e46fbed commit 3b6035d

File tree

78 files changed

+3369
-2789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3369
-2789
lines changed

bin/hbase

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,13 @@ else
305305
# make it easier to check for shaded/not later on.
306306
shaded_jar=""
307307
fi
308+
# here we will add slf4j-api, commons-logging, jul-to-slf4j, jcl-over-slf4j
309+
# to classpath, as they are all logging bridges. Only exclude log4j* so we
310+
# will not actually log anything out. Add it later if necessary
308311
for f in "${HBASE_HOME}"/lib/client-facing-thirdparty/*.jar; do
309312
if [[ ! "${f}" =~ ^.*/htrace-core-3.*\.jar$ ]] && \
310-
[ "${f}" != "htrace-core.jar$" ] && \
311-
[[ ! "${f}" =~ ^.*/slf4j-log4j.*$ ]]; then
313+
[[ "${f}" != "htrace-core.jar$" ]] && \
314+
[[ ! "${f}" =~ ^.*/log4j.*$ ]]; then
312315
CLASSPATH="${CLASSPATH}:${f}"
313316
fi
314317
done
@@ -671,7 +674,7 @@ elif [ "$COMMAND" = "mapredcp" ] ; then
671674
for f in "${HBASE_HOME}"/lib/client-facing-thirdparty/*.jar; do
672675
if [[ ! "${f}" =~ ^.*/htrace-core-3.*\.jar$ ]] && \
673676
[ "${f}" != "htrace-core.jar$" ] && \
674-
[[ ! "${f}" =~ ^.*/slf4j-log4j.*$ ]]; then
677+
[[ ! "${f}" =~ ^.*/log4j.*$ ]]; then
675678
echo -n ":${f}"
676679
fi
677680
done
@@ -720,8 +723,8 @@ elif [ "$COMMAND" = "hbtop" ] ; then
720723
done
721724
fi
722725

723-
if [ -f "${HBASE_HOME}/conf/log4j-hbtop.properties" ] ; then
724-
HBASE_HBTOP_OPTS="${HBASE_HBTOP_OPTS} -Dlog4j.configuration=file:${HBASE_HOME}/conf/log4j-hbtop.properties"
726+
if [ -f "${HBASE_HOME}/conf/log4j2-hbtop.properties" ] ; then
727+
HBASE_HBTOP_OPTS="${HBASE_HBTOP_OPTS} -Dlog4j2.configurationFile=file:${HBASE_HOME}/conf/log4j2-hbtop.properties"
725728
fi
726729
HBASE_OPTS="${HBASE_OPTS} ${HBASE_HBTOP_OPTS}"
727730
else
@@ -810,10 +813,9 @@ fi
810813

811814
HEAP_SETTINGS="$JAVA_HEAP_MAX $JAVA_OFFHEAP_MAX"
812815
# by now if we're running a command it means we need logging
813-
for f in ${HBASE_HOME}/lib/client-facing-thirdparty/slf4j-log4j*.jar; do
816+
for f in ${HBASE_HOME}/lib/client-facing-thirdparty/log4j*.jar; do
814817
if [ -f "${f}" ]; then
815818
CLASSPATH="${CLASSPATH}:${f}"
816-
break
817819
fi
818820
done
819821

bin/hbase.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ set HBASE_OPTS=%HBASE_OPTS% -Djava.util.logging.config.class="org.apache.hadoop.
332332
if not defined HBASE_ROOT_LOGGER (
333333
set HBASE_ROOT_LOGGER=INFO,console
334334
)
335+
335336
set HBASE_OPTS=%HBASE_OPTS% -Dhbase.root.logger="%HBASE_ROOT_LOGGER%"
336337

337338
if defined JAVA_LIBRARY_PATH (
@@ -348,6 +349,7 @@ if not defined HBASE_SECURITY_LOGGER (
348349
set HBASE_SECURITY_LOGGER=INFO,DRFAS
349350
)
350351
)
352+
351353
set HBASE_OPTS=%HBASE_OPTS% -Dhbase.security.logger="%HBASE_SECURITY_LOGGER%"
352354

353355
set HEAP_SETTINGS=%JAVA_HEAP_MAX% %JAVA_OFFHEAP_MAX%

conf/hbase-env.cmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@rem set HBASE_OFFHEAPSIZE=1000
3333

3434
@rem For example, to allocate 8G of offheap, to 8G:
35-
@rem etHBASE_OFFHEAPSIZE=8G
35+
@rem set HBASE_OFFHEAPSIZE=8G
3636

3737
@rem Extra Java runtime options.
3838
@rem Below are what we set by default. May only work with SUN JVM.
@@ -82,6 +82,9 @@ set HBASE_OPTS=%HBASE_OPTS% "-XX:+UseConcMarkSweepGC" "-Djava.net.preferIPv4Stac
8282
@rem Tell HBase whether it should manage it's own instance of ZooKeeper or not.
8383
@rem set HBASE_MANAGES_ZK=true
8484

85+
@rem Tell HBase the logger level and appenders
86+
@rem set HBASE_ROOT_LOGGER=INFO,DRFA
87+
8588
@rem Uncomment to enable trace, you can change the options to use other exporters such as jaeger or
8689
@rem zipkin. See https://github.com/open-telemetry/opentelemetry-java-instrumentation on how to
8790
@rem configure exporters and other components through system properties.

conf/hbase-env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@
126126
# export HBASE_MANAGES_ZK=true
127127

128128
# The default log rolling policy is RFA, where the log file is rolled as per the size defined for the
129-
# RFA appender. Please refer to the log4j.properties file to see more details on this appender.
129+
# RFA appender. Please refer to the log4j2.properties file to see more details on this appender.
130130
# In case one needs to do log rolling on a date change, one should set the environment property
131131
# HBASE_ROOT_LOGGER to "<DESIRED_LOG LEVEL>,DRFA".
132132
# For example:
133-
# HBASE_ROOT_LOGGER=INFO,DRFA
133+
# export HBASE_ROOT_LOGGER=INFO,DRFA
134134
# The reason for changing default to RFA is to avoid the boundary case of filling out disk space as
135135
# DRFA doesn't put any cap on the log size. Please refer to HBase-5655 for more context.
136136

conf/log4j-hbtop.properties

Lines changed: 0 additions & 27 deletions
This file was deleted.

conf/log4j.properties

Lines changed: 0 additions & 139 deletions
This file was deleted.

conf/log4j2-hbtop.properties

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#/**
2+
# * Licensed to the Apache Software Foundation (ASF) under one
3+
# * or more contributor license agreements. See the NOTICE file
4+
# * distributed with this work for additional information
5+
# * regarding copyright ownership. The ASF licenses this file
6+
# * to you under the Apache License, Version 2.0 (the
7+
# * "License"); you may not use this file except in compliance
8+
# * with the License. You may obtain a copy of the License at
9+
# *
10+
# * http://www.apache.org/licenses/LICENSE-2.0
11+
# *
12+
# * Unless required by applicable law or agreed to in writing, software
13+
# * distributed under the License is distributed on an "AS IS" BASIS,
14+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# * See the License for the specific language governing permissions and
16+
# * limitations under the License.
17+
# */
18+
19+
status = warn
20+
dest = err
21+
name = PropertiesConfig
22+
23+
# console
24+
appender.console.type = Console
25+
appender.console.target = SYSTEM_ERR
26+
appender.console.name = console
27+
appender.console.layout.type = PatternLayout
28+
appender.console.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %m%n
29+
30+
rootLogger = WARN,console
31+
32+
# ZooKeeper will still put stuff at WARN
33+
logger.zookeeper.name = org.apache.zookeeper
34+
logger.zookeeper.level = ERROR
35+

0 commit comments

Comments
 (0)