基于AOP(面向切面)记录操作日志
一 、系统服务中的日志存储设计
pojo 逻辑实现
创建Log对象,基于此对象封装用户行为日志
package com.jt.system.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 基于此对象封装用户行为日志
* 谁在什么时间执行了什么操作,访问了什么方法,传递了什么参数,访问时长是多少.
*/
@Data
@TableName("tb_logs")
public class Log implements Serializable {
private static final long serialVersionUID = 3054471551801044482L;
@TableId(type = IdType.AUTO)
private Long id;
private String username;
private String operation;
private String method;
private String params;
private Long time;
private String ip;
@TableField("createdTime")
private Date createdTime;
private Integer status;
private String error;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
dao 逻辑实现
package com.jt.system.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jt.system.pojo.Log;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户行为日志数据层对象
*/
@Mapper
public interface LogMapper extends BaseMapper<Log> {
//有自己特有方法时,可在这里添加
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
创建测试类测试将日志持久化到数据库
package com.jt;
import com.jt.system.dao.LogMapper;
import com.jt.system.pojo.Log;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Date;
@SpringBootTest
public class LogMapperTests {
@Autowired
private LogMapper logMapper;
@Test
void testInsert(){
//构建用户行为日志对象(基于此对象存储一些用户行为日志,先用假数据)
Log log = new Log();
log.setUsername("cgb2107");
log.setIp("10.10.10.10");
log.setOperation("查询资源");
log.setMethod("pkg.ResourceController.doSelect");
log.setParams("");
log.setStatus(1);
log.setTime(100L);
log.setCreatedTime(new Date());
//将日志持久化到数据库
logMapper.insert(log);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
service 逻辑实现
service接口
package com.jt.system.service;
import com.jt.system.pojo.Log;
/**
* 用户行为日志业务逻辑接口定义
*/
public interface LogService {
/**
* 保存用户行为日志
* @param log
*/
void insertLog(Log log);
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
serviceImpl实现类
package com.jt.system.service;
import com.jt.system.dao.LogMapper;
import com.jt.system.pojo.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@Service
public class LogServiceImpl implements LogService{
@Autowired
private LogMapper logMapper;
/**
* @Async注解描述的方法,底层会异步执行
* 不由web服务线程执行,而是交给spring自带的线程池中的线程去执行
* (但是@Async注解,要想起作用,有个前提: 需要在启动类上添加异步执行注解@EnableAsync)
* 优点: 不会长时间阻塞web服务(tomcat)线程
* @param log
*/
@Async
@Override
public void insertLog(Log log) {
logMapper.insert(log);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
controller 逻辑实现
package com.jt.system.controller;
import com.jt.system.pojo.Log;
import com.jt.system.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/log")
public class LogController {
@Autowired
private LogService logService;
@PostMapping
public void doInsertLog(
//@RequestBody 前端传来的参数必须是json
@RequestBody Log log){
logService.insertLog(log);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
Postman提交测试
二 、资源服务日志的获取
业务描述
在不修改目标业务代码实现的基础之上,访问目标方法时,获取用户行为日志
AOP方式获取日志
第一步: 构建一个自定义注解
package com.jt.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 定义RequiredLog注解,通过此注解对需要进行日志记录的方法进行描述
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface RequiredLog {
String value() default "";
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
第二部: 定义一个日志切面,基于此切面中通知方法实现用户行为日志的获取和记录(第一版代码)
package com.jt.aspect;
import com.jt.annotation.RequiredLog;
import com.jt.pojo.Log;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Date;
/**
* @Aspect 注解描述的类型为一个切面类型,在此类中可以定义:
* 1)切入点(切入扩展逻辑的位置~例如权限控制,日志记录,事务处理的位置),在
* @Aspect描述的类中,通常使用@Pointcut注解进行定义.
* 2)通知方法(在切入点对应的目标方法执行前后要执行的逻辑需要写到这样的方法中)在
* @Aspect描述的类中,通过@Before,@After,@Aroud,@AfterReturning,@AfterThrowing
* 这样的注解进行描述
* a: @Before 切入点方法执行之前执行
* b: @After 切入点方法执行之后执行(不管切入点方法是否执行成功了,他都会执行)
* c: @Aroud 切入点方法执行之前和之后都可以执行(最重要)
* d: @AfterReturning 切入点方法成功执行之后执行
* e: @AfterThrowing 切入点方法执行时出现了异常会执行
*/
@Aspect
@Component
public class LogAspect {
/**
* @Pointcut 注解用于定义切入点,此注解中的内容为切入点表达式
* @annotation 为注解方式的切入点表达式,此方式的表达式为一种细粒度的切入点表达式,
* 以为他可以精确到方法,例如我们现在使用RequiredLog注解描述方法时,由他描述的方法
* 就是一个切入点方法
*/
@Pointcut("@annotation(com.jt.annotation.RequiredLog)")
public void doLog(){
//此方法中不需要写任何内容,只负责承载@Pointcut
}
/**
* @Around 注解描述的方法为Aspect中的一个环绕通知方法,
* 在此方法内部可以控制对目标方法的调用.
* @param joinPoint 连接点对象,此对象封装了你要执行的切入点方法信息,可以基于
* 此对象对切入点方法进行反射调用
* @return 目标执行链中切入点方法的返回值
* @throws Throwable
*/
@Around("doLog()")
public Object doAround(ProceedingJoinPoint joinPoint)throws Throwable{
//1. 获取目标对象类型(切入点方法所在类的类型)
Class<?> targetClass = joinPoint.getTarget().getClass();
//2. 获取目标方法
//2.1 获取方法签名(包含方法信息)
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
//2.2 获取方法对象
Method method = targetClass.getDeclaredMethod(
signature.getName(), signature.getParameterTypes());
//3. 获取目标方法上的@RequiredLog注解内容
//3.1 获取目标方法上的注解
RequiredLog requiredLog = method.getAnnotation(RequiredLog.class);
//3.2 获取注解中的内容(这个内容为我们定义的操作名)
String operation = requiredLog.value();
//4. 定义操作状态及结果
int status =1;
String error= "";
Object result=null;
//5. 获取切入点方法执行前的信息
long t1= System.currentTimeMillis();
try {
//手动调用目标执行链(这个执行链中包含切入点方法~目标方法)
result = joinPoint.proceed();
}catch (Throwable e){
status = 0;
error=e.getMessage();
throw e;
}
//获取切入点方法执行之后的信息
long t2 = System.currentTimeMillis();
//7. 将获取的用户行为日志,封装到Log对象
Log logInfo = new Log();
logInfo.setIp("172.18.10.1");/*后续获取*/
//获取用户登录信息(参考了Security官方的代码)
String username = (String)
SecurityContextHolder.getContext()
.getAuthentication()
.getPrincipal();//用户身份
logInfo.setUsername(username);/**/
logInfo.setOperation(operation);
logInfo.setMethod(targetClass.getName()+"."+method.getName());
//获取切入点方法的参数并转成json类型
String params = new ObjectMapper().writeValueAsString(joinPoint.getArgs());
logInfo.setParams(params);
logInfo.setTime(t2-t1);
logInfo.setStatus(status);
logInfo.setCreatedTime(new Date());
logInfo.setError(error);
System.out.println(logInfo);
//后续在这里可以通过Feign将获取的日志传给system工程,进行日志记录
//将Log对象通过Feign或者RestTemplate发送到sso-system工程进行日志记录
//....
return result;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
第二部: 定义一个日志切面,基于此切面中通知方法实现用户行为日志的获取和记录(第一版代码)
package com.jt.aspect;
import com.jt.RemoteLogService;
import com.jt.annotation.RequiredLog;
import com.jt.pojo.Log;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.lang.reflect.Method;
import java.util.Date;
/**
* @Aspect 注解描述的类型为一个切面类型,在此类中可以定义:
* 1)切入点(切入扩展逻辑的位置~例如权限控制,日志记录,事务处理的位置),在
* @Aspect描述的类中,通常使用@Pointcut注解进行定义.
* 2)通知方法(在切入点对应的目标方法执行前后要执行的逻辑需要写到这样的方法中)在
* @Aspect描述的类中,通过@Before,@After,@Aroud,@AfterReturning,@AfterThrowing
* 这样的注解进行描述
* a: @Before 切入点方法执行之前执行
* b: @After 切入点方法执行之后执行(不管切入点方法是否执行成功了,他都会执行)
* c: @Aroud 切入点方法执行之前和之后都可以执行(最重要)
* d: @AfterReturning 切入点方法成功执行之后执行
* e: @AfterThrowing 切入点方法执行时出现了异常会执行
*/
@Aspect
@Component
public class LogAspect {
/**
* @Pointcut 注解用于定义切入点,此注解中的内容为切入点表达式
* @annotation 为注解方式的切入点表达式,此方式的表达式为一种细粒度的切入点表达式,
* 以为他可以精确到方法,例如我们现在使用RequiredLog注解描述方法时,由他描述的方法
* 就是一个切入点方法
*/
@Pointcut("@annotation(com.jt.annotation.RequiredLog)")
public void doLog(){
//此方法中不需要写任何内容,只负责承载@Pointcut
}
/**
* @Around 注解描述的方法为Aspect中的一个环绕通知方法,
* 在此方法内部可以控制对目标方法的调用.
* @param joinPoint 连接点对象,此对象封装了你要执行的切入点方法信息,可以基于
* 此对象对切入点方法进行反射调用
* @return 目标执行链中切入点方法的返回值
* @throws Throwable
*/
@Around("doLog()")
public Object doAround(ProceedingJoinPoint joinPoint)throws Throwable{
//4. 定义操作状态及结果
int status =1; //状态
String error= null; //异常
long time =0l;//执行时长
// 获取切入点方法执行前的时间
long t1= System.currentTimeMillis();
try {
//手动调用目标执行链(这个执行链中包含切入点方法~目标方法)
Object result = joinPoint.proceed();
long t2= System.currentTimeMillis();
time=t2-t1;
return result;
}catch (Throwable e){
long t3 = System.currentTimeMillis();
time=t3-t1;
status = 0;
error=e.getMessage();
throw e;
}finally {
saveLog(joinPoint, time, status, error);
}
}
//存储用户行为日志
private void saveLog(ProceedingJoinPoint joinPoint,long time,
int status,String error)throws Throwable{
//1. 获取目标行为日志
//1.1 获取目标对象类型(切入点方法所在类的类型)
Class<?> targetClass = joinPoint.getTarget().getClass();
//1.2. 获取目标方法
//1.2.1 获取方法签名(包含方法信息)
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
//1.2.2 获取方法对象
Method method = targetClass.getDeclaredMethod(
signature.getName(), signature.getParameterTypes());
//1.3 获取目标方法上的@RequiredLog注解内容
//1.3.1 获取目标方法上的注解
RequiredLog requiredLog = method.getAnnotation(RequiredLog.class);
//1.3.2 获取注解中的内容(这个内容为我们定义的操作名)
String operation = requiredLog.value();
//1.4 获取目标方法名(类名+方法名)
String methodName = targetClass.getName()+"."+method.getName();
//1.5获取切入点方法执行时传入的参数并转成json类型
String params = new ObjectMapper().writeValueAsString(joinPoint.getArgs());
//1.6 获取用户登录信息(参考了Security官方的代码)
String username = (String)
SecurityContextHolder.getContext()
.getAuthentication()
.getPrincipal();//用户身份
//1.7 获取ip地址(从当前线程获取request对象,然后基于request获取ip地址)
ServletRequestAttributes requestAttributes =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
String ip=requestAttributes.getRequest().getRemoteAddr();
//2. 将获取的用户行为日志,封装到Log对象
Log logInfo = new Log();
logInfo.setIp(ip);/*后续获取*/
logInfo.setUsername(username);/**/
logInfo.setOperation(operation);
logInfo.setMethod(methodName);
logInfo.setParams(params);
logInfo.setTime(time);
logInfo.setStatus(status);
logInfo.setCreatedTime(new Date());
logInfo.setError(error);
System.out.println(logInfo);
}
//后续在这里可以通过Feign将获取的日志传给system工程,进行日志记录
//将Log对象通过Feign或者RestTemplate发送到sso-system工程进行日志记录
//....
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
将此注解加到要切入的方法中
Feign方式传递日志(传递给system系统服务)
第一步: 在sso-resource工程添加Feign依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
- 1
- 2
- 3
- 4
第二步: 在sso-resource工程的启动类上添加@EnableFeignClients注解
@EnableFeignClients
@SpringBootApplication
public class ResourceApplication {
public static void main(String[] args) {
SpringApplication.run(ResourceApplication.class, args);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
第三步: 定义日志远程服务调用接口
package com.jt;
import com.jt.pojo.Log;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(value = "sso-system",contextId = "remoteLogService")
public interface RemoteLogService {
@PostMapping("/log")
void doInsertLog(@RequestBody Log log);
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
第四步:在LogAspect类中注入RemoteLogService对象,并通过此对象将日志对象传递到sso-system服务
(更新之后的代码)
package com.jt.aspect;
import com.jt.RemoteLogService;
import com.jt.annotation.RequiredLog;
import com.jt.pojo.Log;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.lang.reflect.Method;
import java.util.Date;
/**
* @Aspect 注解描述的类型为一个切面类型,在此类中可以定义:
* 1)切入点(切入扩展逻辑的位置~例如权限控制,日志记录,事务处理的位置),在
* @Aspect描述的类中,通常使用@Pointcut注解进行定义.
* 2)通知方法(在切入点对应的目标方法执行前后要执行的逻辑需要写到这样的方法中)在
* @Aspect描述的类中,通过@Before,@After,@Aroud,@AfterReturning,@AfterThrowing
* 这样的注解进行描述
* a: @Before 切入点方法执行之前执行
* b: @After 切入点方法执行之后执行(不管切入点方法是否执行成功了,他都会执行)
* c: @Aroud 切入点方法执行之前和之后都可以执行(最重要)
* d: @AfterReturning 切入点方法成功执行之后执行
* e: @AfterThrowing 切入点方法执行时出现了异常会执行
*/
@Aspect
@Component
public class LogAspect {
/**
* @Pointcut 注解用于定义切入点,此注解中的内容为切入点表达式
* @annotation 为注解方式的切入点表达式,此方式的表达式为一种细粒度的切入点表达式,
* 以为他可以精确到方法,例如我们现在使用RequiredLog注解描述方法时,由他描述的方法
* 就是一个切入点方法
*/
@Pointcut("@annotation(com.jt.annotation.RequiredLog)")
public void doLog(){
//此方法中不需要写任何内容,只负责承载@Pointcut
}
/**
* @Around 注解描述的方法为Aspect中的一个环绕通知方法,
* 在此方法内部可以控制对目标方法的调用.
* @param joinPoint 连接点对象,此对象封装了你要执行的切入点方法信息,可以基于
* 此对象对切入点方法进行反射调用
* @return 目标执行链中切入点方法的返回值
* @throws Throwable
*/
@Around("doLog()")
public Object doAround(ProceedingJoinPoint joinPoint)throws Throwable{
//4. 定义操作状态及结果
int status =1; //状态
String error= null; //异常
long time =0l;//执行时长
// 获取切入点方法执行前的时间
long t1= System.currentTimeMillis();
try {
//手动调用目标执行链(这个执行链中包含切入点方法~目标方法)
Object result = joinPoint.proceed();
long t2= System.currentTimeMillis();
time=t2-t1;
return result;
}catch (Throwable e){
long t3 = System.currentTimeMillis();
time=t3-t1;
status = 0;
error=e.getMessage();
throw e;
}finally {
saveLog(joinPoint, time, status, error);
}
}
//存储用户行为日志
private void saveLog(ProceedingJoinPoint joinPoint,long time,
int status,String error)throws Throwable{
//1. 获取目标行为日志
//1.1 获取目标对象类型(切入点方法所在类的类型)
Class<?> targetClass = joinPoint.getTarget().getClass();
//1.2. 获取目标方法
//1.2.1 获取方法签名(包含方法信息)
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
//1.2.2 获取方法对象
Method method = targetClass.getDeclaredMethod(
signature.getName(), signature.getParameterTypes());
//1.3 获取目标方法上的@RequiredLog注解内容
//1.3.1 获取目标方法上的注解
RequiredLog requiredLog = method.getAnnotation(RequiredLog.class);
//1.3.2 获取注解中的内容(这个内容为我们定义的操作名)
String operation = requiredLog.value();
//1.4 获取目标方法名(类名+方法名)
String methodName = targetClass.getName()+"."+method.getName();
//1.5获取切入点方法执行时传入的参数并转成json类型
String params = new ObjectMapper().writeValueAsString(joinPoint.getArgs());
//1.6 获取用户登录信息(参考了Security官方的代码)
String username = (String)
SecurityContextHolder.getContext()
.getAuthentication()
.getPrincipal();//用户身份
//1.7 获取ip地址(从当前线程获取request对象,然后基于request获取ip地址)
ServletRequestAttributes requestAttributes =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
String ip=requestAttributes.getRequest().getRemoteAddr();
//2. 将获取的用户行为日志,封装到Log对象
Log logInfo = new Log();
logInfo.setIp(ip);/*后续获取*/
logInfo.setUsername(username);/**/
logInfo.setOperation(operation);
logInfo.setMethod(methodName);
logInfo.setParams(params);
logInfo.setTime(time);
logInfo.setStatus(status);
logInfo.setCreatedTime(new Date());
logInfo.setError(error);
System.out.println(logInfo);
> //3. 将日志对象通过Feign方式传递到远端服务system
> remoteLogService.doInsertLog(logInfo);
}
//后续在这里可以通过Feign将获取的日志传给system工程,进行日志记录
//将Log对象通过Feign或者RestTemplate发送到sso-system工程进行日志记录
//....
> @Autowired
> private RemoteLogService remoteLogService;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136