@Override
  public void execute(FunctionContext<Object[]> context) {
    InternalCache cache = (InternalCache) context.getCache();
    Map<String, String> result = new HashMap<>();
    try {
      Object[] args = context.getArguments();
      String logLevel = (String) args[0];

      Level log4jLevel = LogLevel.getLevel(logLevel);
      int logWriterLevel = LogLevel.getLogWriterLevel(logLevel);

      cache.getInternalDistributedSystem().getConfig().setLogLevel(logWriterLevel);

      System.setProperty(GeodeGlossary.GEMFIRE_PREFIX + LOG_LEVEL, logLevel);
      logger.info(LogMarker.CONFIG_MARKER, "GFSH Changed log level to {}", log4jLevel);
      result.put(cache.getDistributedSystem().getDistributedMember().getId(),
          "New log level is " + log4jLevel);
      context.getResultSender().lastResult(result);
    } catch (Exception ex) {
      logger.info(LogMarker.CONFIG_MARKER, "GFSH Changing log level exception {}", ex.getMessage(),
          ex);
      result.put(cache.getDistributedSystem().getDistributedMember().getId(),
          "ChangeLogLevelFunction exception " + ex.getMessage());
      context.getResultSender().lastResult(result);
    }
  }
Class for change log level function

@since 8.0
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java