@Test
  public void mainLogWriterLogsToMainLogFile() {
    Properties config = new Properties();
    config.setProperty(LOCATORS, "");
    config.setProperty(LOG_FILE, mainLogFilePath);

    system = (InternalDistributedSystem) DistributedSystem.connect(config);

    DistributionConfig distributionConfig = system.getConfig();
    LogWriterLogger logWriter = (LogWriterLogger) system.getLogWriter();

    await().untilAsserted(() -> assertThat(mainLogFile).exists());

    // CONFIG level

    assertThat(distributionConfig.getLogLevel()).isEqualTo(CONFIG.intLevel());
    assertThat(logWriter.getLogWriterLevel()).isEqualTo(INFO.intLevel());

    String message = createMessage(FINEST);
    logWriter.finest(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(FINER);
    logWriter.finer(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(FINE);
    logWriter.fine(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(CONFIG);
    logWriter.config(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(INFO);
    logWriter.info(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(WARNING);
    logWriter.warning(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(ERROR);
    logWriter.error(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(SEVERE);
    logWriter.severe(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    // FINE level

    distributionConfig.setLogLevel(FINE.intLevel());

    assertThat(distributionConfig.getLogLevel()).isEqualTo(FINE.intLevel());
    assertThat(logWriter.getLogWriterLevel()).isEqualTo(FINE.intLevel());

    message = createMessage(FINEST);
    logWriter.finest(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(FINER);
    logWriter.finer(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(FINE);
    logWriter.fine(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(CONFIG);
    logWriter.config(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(INFO);
    logWriter.info(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(WARNING);
    logWriter.warning(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(ERROR);
    logWriter.error(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(SEVERE);
    logWriter.severe(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    // ERROR level

    distributionConfig.setLogLevel(ERROR.intLevel());

    assertThat(distributionConfig.getLogLevel()).isEqualTo(ERROR.intLevel());
    assertThat(logWriter.getLogWriterLevel()).isEqualTo(ERROR.intLevel());

    message = createMessage(FINEST);
    logWriter.finest(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(FINER);
    logWriter.finer(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(FINE);
    logWriter.fine(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(CONFIG);
    logWriter.config(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(INFO);
    logWriter.info(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(WARNING);
    logWriter.warning(message);
    LogFileAssert.assertThat(mainLogFile).doesNotContain(message);

    message = createMessage(ERROR);
    logWriter.error(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);

    message = createMessage(SEVERE);
    logWriter.severe(message);
    LogFileAssert.assertThat(mainLogFile).contains(message);
  }
Integration tests for logging with {@link InternalDistributedSystem} lifecycle.
geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/LoggingWithDistributedSystemIntegrationTest.java