# 日志注解@AutoLog
URL: /%E6%96%87%E6%A1%A3/04.%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3/02.%20%E5%90%8E%E7%AB%AF%E5%BC%80%E5%8F%91/01.%20%E5%90%8E%E7%AB%AF%E8%A7%84%E8%8C%83/05.%20%E5%B8%B8%E7%94%A8%E6%B3%A8%E8%A7%A3/%E6%97%A5%E5%BF%97%E6%B3%A8%E8%A7%A3@AutoLog


# 日志注解@AutoLog

> jeecg-boot 提供了在线日志管理功能，可以在线实时查看系统登录更新的所有操作。
> jeecg-boot 提供两种方式，写入系统日志

**方式一： 自定义注解@AutoLog**
在 Control 的方法上，加上注解@AutoLog(" 操作内容描述 ")
参考：

```js
     /**
	 *   添加
	 * @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

```js
@Autowired
private BaseCommonService  baseCommonService  ;
```

复制

b. 调用插入日志方法

```js
baseCommonService.addLog("登录失败，用户名:"+username+"不存在！", CommonConstant.LOG_TYPE_1, null);
```

复制
