title: Custom log4j properties in flink
body: <p>How do we pass custom log4j properties from command line in flink run command? I have gone through other questions <a href="https://stackoverflow.com/questions/43940117/apache-flink-dynamically-setting-jvm-opt-env-java-opts">1</a> and <a href="https://stackoverflow.com/questions/46977287/flink-how-to-pass-extra-jvm-options-to-taskmanager-and-jobmanager?rq=1">2</a> but still I am not able to override the existing log4j file where I have custom logging configs.</p>
  
  <p>I have also tried ./bin/flink run -m yarn-cluster -yn 1 -yD env.java.opts="- 
  Dlog4j.configuration=file:///path/to/log4j.properties" ./examples/batch/WordCount.jar</p>
  
  <p>With this I am seeing it getting added to jobmanager logs but the flink client logs still uses the conf/log4j.properties.</p>
  
  <p>I have tried by adding env.java.opts in flink-conf.yaml file and its working but I want to pass the custom log4j.properties from command line. Also when the extra options are passed from flink-conf.yaml I checked that this parameter is set for $FLINK_ENV_JAVA_OPTS in config.sh script. In that case ./bin/flink requires modifications in order to read from custom logs. Something like this </p>
  
  <pre><code>log=$FLINK_LOG_DIR/flink-$FLINK_IDENT_STRING-client-$HOSTNAME.log
  
  if [ "$FLINK_ENV_JAVA_OPTS" ]; then
          log_setting=(-Dlog.file="$log" "$FLINK_ENV_JAVA_OPTS" - 
          Dlogback.configurationFile=file:"$FLINK_CONF_DIR"/logback.xml)
  else
          log_setting=(-Dlog.file="$log" - 
          Dlog4j.configuration=file:"$FLINK_CONF_DIR"/log4j-cli.properties - 
          Dlogback.configurationFile=file:"$FLINK_CONF_DIR"/logback.xml)
  fi
  </code></pre>
  
  <p>Is there any other way of passing custom log4j apart from above options?</p>