private synchronized void switchLogs(final File newLog, final boolean newIsMain) {
    rolling = true;
    try {
      try {
        if (!newIsMain) {
          if (mainLog && mainLogWriter == this && config.getLogFile() != null) {
            // this is the first child. Save the current output stream
            // so we can log special messages to the main log instead
            // of the current child log.
            String metaLogFile =
                getMetaLogFileName(config.getLogFile().getPath(), mainLogId);
            mainLogWriter = new LocalLogWriter(INFO_LEVEL,
                new PrintStream(new FileOutputStream(metaLogFile, true), true));
            if (activeLogFile == null) {
              mainLogWriter.info(String.format("Switching to log %s",
                  config.getLogFile()));
            }
          } else {
            mainLogWriter.info(String.format("Rolling current log to %s", newLog));
          }
        }
        boolean renameOK = true;
        String oldName = config.getLogFile().getAbsolutePath();
        File tempFile = null;
        if (activeLogFile != null) {
          // is a bug that we get here and try to rename the activeLogFile
          // to a newLog of the same name? This works ok on Unix but on windows fails.
          if (!activeLogFile.getAbsolutePath().equals(newLog.getAbsolutePath())) {
            boolean isWindows = false;
            String os = System.getProperty("os.name");
            if (os != null) {
              if (os.contains("Windows")) {
                isWindows = true;
              }
            }
            if (isWindows) {
              // For windows to work we need to redirect everything
              // to a temporary file so we can get oldFile closed down
              // so we can rename it. We don't actually write to this tmp file
              File tempLogDir = rollingFileHandler.getParentFile(config.getLogFile());
              tempFile = File.createTempFile("mlw", null, tempLogDir);
              // close the old print writer down before we do the rename
              // do not redirect if loner -- see #49492
              PrintStream tempPrintStream = OSProcess.redirectOutput(tempFile, !loner);
              PrintWriter oldPrintWriter = setTarget(new PrintWriter(tempPrintStream, true));
              if (oldPrintWriter != null) {
                oldPrintWriter.close();
              }
            }
            File oldFile = activeLogFile;
            renameOK = LogFileUtils.renameAggressively(oldFile, newLog.getAbsoluteFile());
            if (!renameOK) {
              mainLogWriter
                  .warning("Could not delete original file '" + oldFile + "' after copying to '"
                      + newLog.getAbsoluteFile() + "'. Continuing without rolling.");
            } else {
              renameOK = true;
            }
          }
        }
        activeLogFile = new File(oldName);
        // Don't redirect sysouts/syserrs to client log file. See #49492.
        // IMPORTANT: This assumes that only a loner would have sendAlert set to false.
        PrintStream printStream = OSProcess.redirectOutput(activeLogFile, !loner);
        PrintWriter oldPrintWriter =
            setTarget(new PrintWriter(printStream, true), activeLogFile.length());
        if (oldPrintWriter != null) {
          oldPrintWriter.close();
        }
        if (tempFile != null) {
          tempFile.delete();
        }
        mainLog = newIsMain;
        if (mainLogWriter == null) {
          mainLogWriter = this;
        }
        if (!renameOK) {
          mainLogWriter.warning("Could not rename \"" + activeLogFile + "\" to \"" + newLog
              + "\". Continuing without rolling.");
        }
      } catch (IOException ex) {
        mainLogWriter.warning("Could not open log \"" + newLog + "\" because " + ex);
      }
      checkDiskSpace(activeLogFile);
    } finally {
      rolling = false;
    }
  }
Call when the config changes at runtime.
geode-core/src/main/java/org/apache/geode/internal/logging/ManagerLogWriter.java