From d139bde248b114e904a9cf45bccd20d97dafd99b Mon Sep 17 00:00:00 2001
From: miomiocat <284487410@qq.com>
Date: Sun, 25 Jun 2023 17:33:00 +0800
Subject: [PATCH] [Enhancement] Separate JNI logs from be.out (#25826)
- separate JNI logs from be.out
- rolling out config
- provide log4j-1 compatibility using [log4j 1.2
bridge](https://logging.apache.org/log4j/2.x/log4j-1.2-api.html)
Signed-off-by: miomiocat <284487410@qq.com>
---
be/CMakeLists.txt | 2 +-
build.sh | 2 +-
conf/log4j.properties | 19 -------------------
conf/log4j2.properties | 21 +++++++++++++++++++++
java-extensions/java-utils/pom.xml | 8 ++++++++
java-extensions/paimon-reader/pom.xml | 1 -
java-extensions/pom.xml | 2 +-
7 files changed, 32 insertions(+), 23 deletions(-)
delete mode 100644 conf/log4j.properties
create mode 100644 conf/log4j2.properties
diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 3f414e23b92..f0cf5e257a8 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -972,7 +972,7 @@ install(FILES
${BASE_DIR}/../conf/be_test.conf
${BASE_DIR}/../conf/cn.conf
${BASE_DIR}/../conf/hadoop_env.sh
- ${BASE_DIR}/../conf/log4j.properties
+ ${BASE_DIR}/../conf/log4j2.properties
DESTINATION ${OUTPUT_DIR}/conf)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "ASAN" OR "${CMAKE_BUILD_TYPE}" STREQUAL "LSAN")
diff --git a/build.sh b/build.sh
index d8619f3a8fe..0cf742c4a88 100755
--- a/build.sh
+++ b/build.sh
@@ -420,7 +420,7 @@ if [ ${BUILD_BE} -eq 1 ]; then
cp -r -p ${STARROCKS_HOME}/be/output/conf/be_test.conf ${STARROCKS_OUTPUT}/be/conf/
cp -r -p ${STARROCKS_HOME}/be/output/conf/cn.conf ${STARROCKS_OUTPUT}/be/conf/
cp -r -p ${STARROCKS_HOME}/be/output/conf/hadoop_env.sh ${STARROCKS_OUTPUT}/be/conf/
- cp -r -p ${STARROCKS_HOME}/be/output/conf/log4j.properties ${STARROCKS_OUTPUT}/be/conf/
+ cp -r -p ${STARROCKS_HOME}/be/output/conf/log4j2.properties ${STARROCKS_OUTPUT}/be/conf/
if [ "${BUILD_TYPE}" == "ASAN" ]; then
cp -r -p ${STARROCKS_HOME}/be/output/conf/asan_suppressions.conf ${STARROCKS_OUTPUT}/be/conf/
fi
diff --git a/conf/log4j.properties b/conf/log4j.properties
deleted file mode 100644
index caf2c2f977c..00000000000
--- a/conf/log4j.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2021-present StarRocks, Inc. All rights reserved.
-#
-# Licensed 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
-#
-# https:#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=ERROR, stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.target=System.err
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p [%t] %F(%M:%L): %m%n
diff --git a/conf/log4j2.properties b/conf/log4j2.properties
new file mode 100644
index 00000000000..db52f6201e2
--- /dev/null
+++ b/conf/log4j2.properties
@@ -0,0 +1,21 @@
+status = error
+dest = out
+name = PropertiesConfig
+
+appender.rolling.type = RollingFile
+appender.rolling.name = rollingFileAppender
+appender.rolling.fileName = ${env:STARROCKS_HOME:-/tmp}/log/jni.INFO.log
+appender.rolling.filePattern = ${env:STARROCKS_HOME:-/tmp}/log/jni.INFO.log.%d{yyyyMMdd}
+appender.rolling.layout.type = PatternLayout
+appender.rolling.layout.pattern = %d{yy/MM/dd HH:mm:ss} %p [%t] %M(%F:%L): %m%n
+appender.rolling.policies.type = Policies
+appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
+appender.rolling.policies.time.interval = 1
+appender.rolling.policies.time.modulate = false
+appender.rolling.strategy.type = DefaultRolloverStrategy
+appender.rolling.strategy.max = 7
+
+rootLogger = INFO, rollingFileAppender
+
+#logger.hdfs.name = org.apache.hadoop.hdfs
+#logger.hdfs.level = DEBUG
diff --git a/java-extensions/java-utils/pom.xml b/java-extensions/java-utils/pom.xml
index 9e48a4ef0b7..83baf8f36ff 100644
--- a/java-extensions/java-utils/pom.xml
+++ b/java-extensions/java-utils/pom.xml
@@ -20,6 +20,14 @@
UTF-8
+
+
+ org.apache.logging.log4j
+ log4j-1.2-api
+ ${log4j.version}
+
+
+
starrocks-java-utils
diff --git a/java-extensions/paimon-reader/pom.xml b/java-extensions/paimon-reader/pom.xml
index 7124aaedf82..7a629ae2561 100644
--- a/java-extensions/paimon-reader/pom.xml
+++ b/java-extensions/paimon-reader/pom.xml
@@ -16,7 +16,6 @@
8
${basedir}/../
0.4.0-incubating
- 2.17.1
1.7.32
diff --git a/java-extensions/pom.xml b/java-extensions/pom.xml
index 27972d976ac..f07b7156b94 100644
--- a/java-extensions/pom.xml
+++ b/java-extensions/pom.xml
@@ -24,7 +24,7 @@
1.8
1.8
3.4.5
- 2.17.1
+ 2.19.0
3.8.1
${basedir}