代码拉取完成,页面将自动刷新
同步操作将从 xsx/slf4j-spring-boot-starter 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
一个注解搞定日志的组件,减少到处编写日志的烦恼,还可定位代码哟
依赖spring-boot-starter-aop
AOP + Reflect
任意由spring调用的方法
<dependency>
<groupId>wiki.xsx</groupId>
<artifactId>spring-boot-starter-slf4j</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>wiki.xsx</groupId>
<artifactId>spring-boot-starter-slf4j</artifactId>
<version>RELEASE</version>
</dependency>
yml方式:
logging:
level:
wiki.xsx.log: 对应级别
properties方式:
logging.level.wiki.xsx.log: 对应级别
例如:
@Service
public class TestService {
@ParamLog("test1")
public void test1() {}
@ResultLog("test2")
public void test2(String name) {}
@ThrowingLog("test3")
public void test3(String name, int id) {}
@Log("test4")
public void test4(String name, int ...id) {}
}
方法调用:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class, args);
TestService bean = context.getBean(TestService.class);
bean.test1();
bean.test2("xsx");
bean.test3("xsx`", 1);
bean.test4("xsx2", 1, 2, 3, 4);
}
}
打印效果:
2019-06-20 00:53:32.390 DEBUG 7932 --- [ main] wiki.xsx.core.log.LogProcessor : 调用方法:【com.example.demo.service.TestService.test1(TestService.java:19)】,业务名称:【test1】,接收参数:【{}】
2019-06-20 00:53:32.405 DEBUG 7932 --- [ main] wiki.xsx.core.log.LogProcessor : 调用方法:【com.example.demo.service.TestService.test2(TestService.java:22)】,业务名称:【test2】,返回结果:【null】
2019-06-20 00:53:32.412 DEBUG 7932 --- [ main] wiki.xsx.core.log.LogProcessor : 调用方法:【com.example.demo.service.TestService.test4(TestService.java:28)】,业务名称:【test4】,接收参数:【{name=xsx2, id=[1, 2, 3, 4]}】
2019-06-20 00:53:32.413 DEBUG 7932 --- [ main] wiki.xsx.core.log.LogProcessor : 调用方法:【com.example.demo.service.TestService.test4(TestService.java:28)】,业务名称:【test4】,返回结果:【null】
CPU | AMD Athlon(tm) II X4 640 Processor(3000 Mhz) |
内存 | 8.00 GB (1333 MHz) |
硬盘 | Apacer A S510S 128GB SATA Disk Device |
测试工具 | Apache JMeter 5.1.1 |
测试方式 | http请求测试日志打印,循环5次取最后1次 |
加入代码定位功能:
日志类型 | 并发数 | 单次平均耗时(毫秒) | 吞吐量(请求次数/每秒) |
---|---|---|---|
@ParamLog | 1000 | 136 | 484 |
@ResultLog | 1000 | 86 | 417 |
@Log | 1000 | 29 | 425 |
取消代码定位功能:
日志类型 | 并发数 | 单次平均耗时(毫秒) | 吞吐量(请求次数/每秒) |
---|---|---|---|
@ParamLog | 1000 | 274 | 491 |
@ResultLog | 1000 | 66 | 519 |
@Log | 1000 | 108 | 483 |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。