Aop日志

master
张小东 2023-11-21 22:41:53 +08:00
parent 7450eb713e
commit 71a48c3ec9
6 changed files with 19 additions and 12 deletions

View File

@ -57,7 +57,18 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<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>
</dependencies>
<build>

View File

@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication
@EnableAspectJAutoProxy
public class TrajectoryApplication {

View File

@ -1,8 +1,8 @@
package com.february.common.domain.aspect;
package com.vehicle.trajectory.aspect;
import java.lang.annotation.*;
/**
*
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})

View File

@ -1,4 +1,4 @@
package com.february.common.domain.aspect;
package com.vehicle.trajectory.aspect;
import com.google.gson.Gson;
import org.aspectj.lang.JoinPoint;
@ -24,7 +24,7 @@ public class WebLogAspect {
private static final Gson gson = new Gson(); // 用于重复使用Gson实例
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() {}
@Before("webLog()")

View File

@ -5,7 +5,7 @@ import com.february.common.core.domain.Result;
import com.february.common.domain.RealData;
import com.february.common.domain.Vehicle;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -23,9 +23,4 @@ spring:
# 共享配置
shared-configs:
- 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'