2

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.

jackb
  • 695
  • 8
  • 26

3 Answers3

2
public static ExecutionEnvironment setupLocalEnvironment() {
     Configuration conf = new Configuration();
      env = new LocalEnvironment(conf);
      env.getConfig().disableSysoutLogging();
      return env;
}
jackb
  • 695
  • 8
  • 26
  • Flink changed a bit, and my issue was on an old version. Did you test it on Runtime 2.11 and Flink Core 1.1.2? – jackb Jul 23 '18 at 19:16
1

First, you need to figure out whether you are using slf4j + logback, or slf4j + log4j. If you use slf4j + log4j, then disable log4j by

log4j.rootLogger=OFF

else is you use slf4j + logback, then disable logback by

<!-- This affects logging for both user code and Flink -->
<root level="OFF">
    <appender-ref ref="file"/>
</root>
begginghard
  • 141
  • 1
  • 5
  • Thanks, the first approach worked for me. All I had to do was find the _log4j.properties_ file in _src\main\resources_ and edit the appropriate line. – h4nek Jun 27 '19 at 07:50
0

Can you try this in your Main function :

org.apache.log4j.BasicConfigurator.configure(new NullAppender());

I have a doubt for your version, but give it a try.

ImbaBalboa
  • 851
  • 9
  • 23