public static Map<String, String> setLoggerLevel(String loggerName, String logLevel) {
    Level level;
    try {
      level = Level.valueOf(logLevel);
    } catch (Exception e) {
      throw new RuntimeException("Unrecognized logger level - " + logLevel, e);
    }
    LoggerContext context = (LoggerContext) LogManager.getContext(false);
    Configuration config = context.getConfiguration();
    LoggerConfig loggerConfig;
    if (getAllConfiguredLoggers().contains(loggerName)) {
      loggerConfig = getLoggerConfig(config, loggerName);
      loggerConfig.setLevel(level);
    } else {
      // Check if the loggerName exists by comparing it to all known loggers in the context
      if (getAllLoggers().stream().noneMatch(logger -> {
        if (!logger.startsWith(loggerName)) {
          return false;
        }
        if (logger.equals(loggerName)) {
          return true;
        }
        // Check if loggerName is a valid parent / descendant logger for any known logger
        return logger.substring(loggerName.length()).startsWith(".");
      })) {
        throw new RuntimeException("Logger - " + loggerName + " not found");
      }
      loggerConfig = new LoggerConfig(loggerName, level, true);
      config.addLogger(loggerName, loggerConfig);
    }
    // This causes all Loggers to re-fetch information from their LoggerConfig.
    context.updateLoggers();
    return getLoggerResponse(loggerConfig);
  }
@Test
  public void testChangeLoggerLevelWithExceptions() {
    try {
      LoggerUtils.setLoggerLevel("notExistLogger", "INFO");
      fail("Shouldn't reach here");
    } catch (RuntimeException e) {
      assertEquals(e.getMessage(), "Logger - notExistLogger not found");
    }
    try {
      LoggerUtils.setLoggerLevel(ROOT, "NotALevel");
      fail("Shouldn't reach here");
    } catch (RuntimeException e) {
      assertEquals(e.getMessage(), "Unrecognized logger level - NotALevel");
    }
  }