From 3ade078e3a6a320c9bc322e3866ca5399abedfb8 Mon Sep 17 00:00:00 2001 From: wforget <643348094@qq.com> Date: Tue, 19 Mar 2024 14:35:53 +0800 Subject: [PATCH] [KYUUBI #6196] Add log4j2 template for kyuubi repl commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # :mag: Description ## Issue References ๐Ÿ”— This pull request fixes # ## Describe Your Solution ๐Ÿ”ง Add log4j2 template for kyuubi repl command. Since I want to add rolling logs for kyuubi server, we need to add independent log4j properties for kyuubi repl command. ## Types of changes :bookmark: - [ ] Bugfix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan ๐Ÿงช #### Behavior Without This Pull Request :coffin: #### Behavior With This Pull Request :tada: #### Related Unit Tests --- # Checklist ๐Ÿ“ - [X] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6196 from wForget/log4j_repl. Closes #6196 d8d64644d [wforget] newline 10a5b9fff [wforget] remove filter a775ee2d5 [wforget] Add log4j2 template for kyuubi repl command Authored-by: wforget <643348094@qq.com> Signed-off-by: Cheng Pan (cherry picked from commit 31469fa7a63861edc5adaecb917eb409b1eb31ed) --- bin/beeline | 4 ++++ bin/kyuubi-admin | 4 ++++ bin/kyuubi-ctl | 4 ++++ bin/kyuubi-zk-cli | 6 +++++- conf/log4j2-repl.xml.template | 33 +++++++++++++++++++++++++++++++++ conf/log4j2.xml.template | 5 +---- 6 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 conf/log4j2-repl.xml.template diff --git a/bin/beeline b/bin/beeline index 3581f6dd6bd..9fd2c9ba02a 100755 --- a/bin/beeline +++ b/bin/beeline @@ -50,4 +50,8 @@ else KYUUBI_BEELINE_CLASSPATH="${KYUUBI_BEELINE_JARS}/*:${HADOOP_CONF_DIR}:${YARN_CONF_DIR}" fi +if [[ -f ${KYUUBI_CONF_DIR}/log4j2-repl.xml ]]; then + KYUUBI_CTL_JAVA_OPTS="${KYUUBI_CTL_JAVA_OPTS} -Dlog4j2.configurationFile=log4j2-repl.xml" +fi + exec ${RUNNER} ${KYUUBI_BEELINE_OPTS} -cp ${KYUUBI_BEELINE_CLASSPATH} $CLASS "$@" diff --git a/bin/kyuubi-admin b/bin/kyuubi-admin index a1f176ec157..689b626dd9f 100755 --- a/bin/kyuubi-admin +++ b/bin/kyuubi-admin @@ -45,4 +45,8 @@ else KYUUBI_CLASSPATH="${KYUUBI_JAR_DIR}/*:${KYUUBI_CONF_DIR}:${HADOOP_CONF_DIR}:${YARN_CONF_DIR}" fi +if [[ -f ${KYUUBI_CONF_DIR}/log4j2-repl.xml ]]; then + KYUUBI_CTL_JAVA_OPTS="${KYUUBI_CTL_JAVA_OPTS} -Dlog4j2.configurationFile=log4j2-repl.xml" +fi + exec ${RUNNER} ${KYUUBI_CTL_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS "$@" diff --git a/bin/kyuubi-ctl b/bin/kyuubi-ctl index 16809c0754b..10e1121251d 100755 --- a/bin/kyuubi-ctl +++ b/bin/kyuubi-ctl @@ -45,4 +45,8 @@ else KYUUBI_CLASSPATH="${KYUUBI_JAR_DIR}/*:${KYUUBI_CONF_DIR}:${HADOOP_CONF_DIR}:${YARN_CONF_DIR}" fi +if [[ -f ${KYUUBI_CONF_DIR}/log4j2-repl.xml ]]; then + KYUUBI_CTL_JAVA_OPTS="${KYUUBI_CTL_JAVA_OPTS} -Dlog4j2.configurationFile=log4j2-repl.xml" +fi + exec ${RUNNER} ${KYUUBI_CTL_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS "$@" diff --git a/bin/kyuubi-zk-cli b/bin/kyuubi-zk-cli index f503c3e5a5e..00da1f485e3 100755 --- a/bin/kyuubi-zk-cli +++ b/bin/kyuubi-zk-cli @@ -45,4 +45,8 @@ else KYUUBI_CLASSPATH="${KYUUBI_JAR_DIR}/*:${KYUUBI_CONF_DIR}:${HADOOP_CONF_DIR}:${YARN_CONF_DIR}" fi -exec ${RUNNER} ${KYUUBI_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS "$@" \ No newline at end of file +if [[ -f ${KYUUBI_CONF_DIR}/log4j2-repl.xml ]]; then + KYUUBI_CTL_JAVA_OPTS="${KYUUBI_CTL_JAVA_OPTS} -Dlog4j2.configurationFile=log4j2-repl.xml" +fi + +exec ${RUNNER} ${KYUUBI_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS "$@" diff --git a/conf/log4j2-repl.xml.template b/conf/log4j2-repl.xml.template new file mode 100644 index 00000000000..0c5fc78b2d3 --- /dev/null +++ b/conf/log4j2-repl.xml.template @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + diff --git a/conf/log4j2.xml.template b/conf/log4j2.xml.template index 215fddf47f4..c2db4c4750d 100644 --- a/conf/log4j2.xml.template +++ b/conf/log4j2.xml.template @@ -30,9 +30,6 @@ - - - @@ -55,7 +52,7 @@ - +