public Properties build() {
    checkNotNull(logDir, config);
    checkState(jsonOutput || (logPattern != null), "log pattern must be specified if not using json output");
    configureGlobalFileLog();
    if (allLogsToConsole) {
      configureGlobalStdoutLog();
    }

    ofNullable(logLevelConfig).ifPresent(this::applyLogLevelConfiguration);

    Properties res = new Properties();
    res.putAll(log4j2Properties);
    return res;
  }
@Test
  public void buildLogPattern_does_not_put_threadIdFieldPattern_from_RootLoggerConfig_is_null() {
    String pattern = newLog4JPropertiesBuilder().buildLogPattern(
      newRootLoggerConfigBuilder()
        .setProcessId(ProcessId.COMPUTE_ENGINE)
        .build());

    assertThat(pattern).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level ce[][%logger{1.}] %msg%n");
  }