@GetMapping("setLoggerLevel") public R setLogger(String level, HttpServletRequest request) { String packageName = "com.xxx.xxx.xxx"; LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); switch (level) { case "error": loggerContext.getLogger(packageName).setLevel(Level.ERROR); break; case "warn": loggerContext.getLogger(packageName).setLevel(Level.WARN); break; case "info": loggerContext.getLogger(packageName).setLevel(Level.INFO); break; case "debug": loggerContext.getLogger(packageName).setLevel(Level.DEBUG); break; default: return R.error("参数错误"); } return R.ok("日志级别已经设置为" + level); }