Aop日志
parent
7450eb713e
commit
71a48c3ec9
|
@ -57,7 +57,18 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.5</version>
|
<version>2.8.9</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 引入 Spring Boot Starter 包括了默认的日志依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 如果需要单独引入日志依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableAspectJAutoProxy
|
@EnableAspectJAutoProxy
|
||||||
public class TrajectoryApplication {
|
public class TrajectoryApplication {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.february.common.domain.aspect;
|
package com.vehicle.trajectory.aspect;
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切面
|
* 切面类
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.METHOD})
|
@Target({ElementType.METHOD})
|
|
@ -1,4 +1,4 @@
|
||||||
package com.february.common.domain.aspect;
|
package com.vehicle.trajectory.aspect;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
@ -24,7 +24,7 @@ public class WebLogAspect {
|
||||||
private static final Gson gson = new Gson(); // 用于重复使用Gson实例
|
private static final Gson gson = new Gson(); // 用于重复使用Gson实例
|
||||||
private static final String LINE_SEPARATOR = System.lineSeparator();
|
private static final String LINE_SEPARATOR = System.lineSeparator();
|
||||||
|
|
||||||
@Pointcut("@annotation(com.february.common.domain.aspect.WebLog)")
|
@Pointcut("@annotation(com.vehicle.trajectory.aspect.WebLog)")
|
||||||
public void webLog() {}
|
public void webLog() {}
|
||||||
|
|
||||||
@Before("webLog()")
|
@Before("webLog()")
|
|
@ -5,7 +5,7 @@ import com.february.common.core.domain.Result;
|
||||||
import com.february.common.domain.RealData;
|
import com.february.common.domain.RealData;
|
||||||
import com.february.common.domain.Vehicle;
|
import com.february.common.domain.Vehicle;
|
||||||
import com.february.common.domain.VehicleType;
|
import com.february.common.domain.VehicleType;
|
||||||
import com.february.common.domain.aspect.WebLog;
|
import com.vehicle.trajectory.aspect.WebLog;
|
||||||
import com.vehicle.trajectory.service.TrajectoryService;
|
import com.vehicle.trajectory.service.TrajectoryService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
|
@ -23,9 +23,4 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# application.yml
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.vehicle.trajectory.controller: INFO
|
|
||||||
pattern:
|
|
||||||
console: '%d{yyyy-MM-dd HH:mm:ss} - %msg%n'
|
|
||||||
|
|
Loading…
Reference in New Issue