Search code examples
javadistributed-computingapache-flink

Disable Apache Flink Logging


I'm using an old version of Apache Flink, with Runtime 2.11 and Flink Core 1.1.2. I cannot upgrade it to the newer Apache Flink due to compatibility issues to other libraries. I'm trying to disable the node logging on the Runtime in order to minimize the execution time. I tried to use the following code, but the messages are displayed nethertheless:

Log4jLoggerAdapter logger = (Log4jLoggerAdapter)LoggerFactory
  .getLogger(JobManager.class);
Field loggerField = Log4jLoggerAdapter.class.getDeclaredField("logger");
loggerField.setAccessible(true);
Logger loggerObject = (Logger)loggerField.get(logger);


Field repoField = Category.class.getDeclaredField("repository");
repoField.setAccessible(true);
LoggerRepository repoObject = (LoggerRepository)repoField.get(loggerObject);

repoObject.setThreshold(Level.OFF);

Plus, I'd like to know if there is a way to extimate the number of messages exchanged within each phase of the Execution Plan.


Solution

  • public static ExecutionEnvironment setupLocalEnvironment() {
         Configuration conf = new Configuration();
          env = new LocalEnvironment(conf);
          env.getConfig().disableSysoutLogging();
          return env;
    }