public void setLoggerLevel(LoggerRequest loggerRequest) throws BadRequestException {
    try {
      Class.forName(loggerRequest.getName());
    } catch (Throwable ignore) {
      throw new BadRequestException(
          "The class of '" + loggerRequest.getName() + "' doesn't exists");
    }

    org.apache.log4j.Logger logger = LogManager.getLogger(loggerRequest.getName());
    if (null == logger) {
      throw new BadRequestException("The name of the logger is wrong");
    }

    org.apache.log4j.Level level = org.apache.log4j.Level.toLevel(loggerRequest.getLevel(), null);
    if (null == level) {
      throw new BadRequestException("The level of the logger is wrong");
    }

    logger.setLevel(level);
  }
@Test
  void testSetLoggerLevel() {
    AdminService adminService = new AdminService();
    String testLoggerName = "test";
    org.apache.log4j.Logger logger = adminService.getLogger(testLoggerName);
    org.apache.log4j.Level level = logger.getLevel();
    boolean setInfo = false;
    if (org.apache.log4j.Level.INFO == level) {
      // if a current level is INFO, set DEBUG to check if it's changed or not
      logger.setLevel(org.apache.log4j.Level.DEBUG);
    } else {
      logger.setLevel(org.apache.log4j.Level.INFO);
      setInfo = true;
    }

    logger = adminService.getLogger(testLoggerName);
    assertTrue((setInfo && org.apache.log4j.Level.INFO == logger.getLevel())
      || (!setInfo && Level.DEBUG == logger.getLevel()), "Level of logger should be changed");
  }