public Properties createProperties(Props props, File logDir) {
    Log4JPropertiesBuilder log4JPropertiesBuilder = new Log4JPropertiesBuilder(props);
    RootLoggerConfig config = newRootLoggerConfigBuilder()
      .setNodeNameField(getNodeNameWhenCluster(props))
      .setProcessId(ProcessId.ELASTICSEARCH)
      .build();

    String logPattern = log4JPropertiesBuilder.buildLogPattern(config);

    return log4JPropertiesBuilder.internalLogLevel(Level.ERROR)
      .rootLoggerConfig(config)
      .logPattern(logPattern)
      .enableAllLogsToConsole(isAllLogsToConsoleEnabled(props))
      .jsonOutput(isJsonOutput(props))
      .logDir(logDir)
      .logLevelConfig(
        LogLevelConfig.newBuilder(log4JPropertiesBuilder.getRootLoggerName())
          .rootLevelFor(ProcessId.ELASTICSEARCH)
          .build())
      .build();
  }
@Test
  public void createProperties_sets_root_logger_to_process_property_if_set() throws IOException {
    File logDir = temporaryFolder.newFolder();
    Properties properties = underTest.createProperties(newProps("sonar.log.level.es", "DEBUG"), logDir);

    assertThat(properties.getProperty("rootLogger.level")).isEqualTo("DEBUG");
  }