系统日志怎么插入? === > jeecg-boot 提供了在线日志管理功能,可以在线实时查看系统登录更新的所有操作。 > jeecg-boot提供两种方式,写入系统日志 **方式一: 自定义注解@AutoLog** 在Control的方法上,加上注解@AutoLog("操作内容描述") 参考: ``` /** * 添加 * @param jeecgDemo * @return */ @RequestMapping(value = "/add", method = RequestMethod.POST) @AutoLog(value = "添加测试DEMO") public Result<JeecgDemo> add(@RequestBody JeecgDemo jeecgDemo) { Result<JeecgDemo> result = new Result<JeecgDemo>(); try { jeecgDemoService.save(jeecgDemo); result.success("添加成功!"); } catch (Exception e) { e.printStackTrace(); log.info(e.getMessage()); result.error500("操作失败"); } return result; } ``` **方式二: 调用共通API插入日志(新版)** a. 引入共通service ``` @Autowired private BaseCommonService baseCommonService ; ``` b. 调用插入日志方法 ``` baseCommonService.addLog("登录失败,用户名:"+username+"不存在!", CommonConstant.LOG_TYPE_1, null); ``` **~~方式二: 调用共通API插入日志——老版本~~** a. 引入共通service ``` @Autowired private ISysBaseAPI sysBaseAPI; ``` b. 调用插入日志方法 ``` sysBaseAPI.addLog("登录失败,用户名:"+username+"不存在!", CommonConstant.LOG_TYPE_1, null); ```