fapaul commented on a change in pull request #11583: [FLINK-16883] Scan 
FLINK_CONF directory for available log4j configura…
URL: https://github.com/apache/flink/pull/11583#discussion_r401458060
 
 

 ##########
 File path: flink-dist/src/main/flink-bin/bin/config.sh
 ##########
 @@ -645,3 +645,20 @@ extractExecutionParams() {
 
     echo ${execution_config} | sed "s/$EXECUTION_PREFIX//"
 }
+
+findLog4jConfiguration() {
+    local PATH=$1
+    local LOG4J_CONFIG_FILES=($PATH/log4j-console.*)
+    if [[ ${#LOG4J_CONFIG_FILES[@]} -gt 1 ]]; then
+        echo "[ERROR] Found more than one log4j configuration file: 
[${LOG4J_CONFIG_FILES[@]}]" 1>&2
+        exit 1
+    fi
+
+    LOG4J_CONFIG=${LOG4J_CONFIG_FILES[0]}
+    if [[ "${LOG4J_CONFIG: -1}" = "*" ]]; then
+        echo "[ERROR] Could not find a valid configuration" 1>&2
+        exit 1
+    fi
 
 Review comment:
   > I don't understand this block. If we wanted to check whether there were 
any `log4j-console.*` files, couldn't we check for an empty array in the 
previous if-block?
   > 
   > What does `if [[ "${LOG4J_CONFIG: -1}" = "*" ]]; then` test?
   
   The problem, I experienced, is that the query `($PATH/log4j-console.*)` 
returns itself if no matches were found. This means the array will never be 
empty and therefore the additional check.
   
   > What if the user uses logback, will this fail then?
   
   It should not be affected right now since it is set through a different java 
configuration setting `-Dlogback.configurationFile`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to