http://59.110.164.254:8066/login.html 用户名/密码:admin/admin
http://47.98.236.203:3000 用户名/密码:admin/1q2w3e4r
入群学习:(备注:Coder编程) 群1:483725710(满2000) 群2:897924507
本章主要是将ocp原来的log-core做一个代码优化,采用spring boot enable的方式重构代码。
pom依赖
LogServiceImpl 切换数据源,记录log表
LogServiceImpl 切换数据源,记录log表
AOP标准日志格式
springboot项目中是否使用过EnableCaching
下面咱们按照springboot的方式 编写EnableLogging
@Import(LogImportSelector.class)
LogImportSelector
使用EnableLogging
总结 1.@Import用来导入一个或多个类(会被spring容器托管),或者配置类(配置类里面的bean都会被spring容器托管) 2. ImportSelector 该接口的方法的返回值都会被纳入到spring容器管理中
HP@owen /cygdrive/d/open-capacity-platform $ grep -rn a26003208271fd94 * logs/auth-gateway/auth-gateway-info.log:740:[auth-gateway:130.75.131.208:9200] [a26003208271fd94] [a26003208271fd94] 2019-09-06 09:38:33.898 INFO 6364 [XNIO-2 task-3] com.open.capacity.client.filter.ResponseFilter request url = http://127.0.0.1:9200/api-auth/validata/code/1263967C-FED7-4732-86D7-8CC6BDF752F5, traceId = a26003208271fd94 logs/auth-gateway/auth-gateway-info.log:741:[auth-gateway:130.75.131.208:9200] [a26003208271fd94] [a26003208271fd94] 2019-09-06 09:38:36.703 INFO 6364 [XNIO-2 task-3] com.open.capacity.client.filter.ResponseFilter response url http://127.0.0.1:9200/api-auth/validata/code/1263967C-FED7-4732-86D7-8CC6BDF752F5, traceId = a26003208271fd94 oauth-center/logs/auth-server/auth-server-info.log:722:[auth-server:130.75.131.208:8000] [a26003208271fd94] [b26ed6e6877dd47a] 2019-09-06 09:38:34.795 INFO 15168 [http-nio-8000-exec-1] com.open.capacity.log.aop.LogAnnotationAOP 开始请求,transid=a26003208271fd94, url=com.open.capacity.uaa.server.controller.ValidateCodeController/createCode , httpMethod=null, reqData=["1263967C-FED7-4732-86D7-8CC6BDF752F5"] oauth-center/logs/auth-server/auth-server-info.log:723:[auth-server:130.75.131.208:8000] [a26003208271fd94] [b26ed6e6877dd47a] 2019-09-06 09:38:36.671 INFO 15168 [http-nio-8000-exec-1] com.open.capacity.log.aop.LogAnnotationAOP 请求完成, transid=a26003208271fd94, 耗时=1898, resp=null: 复制代码
[test-log-center:130.75.131.208:8080] [,d1d8bf482db0af10] 2019-09-16 13:40:25.181 INFO 18088 [http-nio-8080-exec-10] com.open.capacity.log.test.controller.TestController ok [test-log-center:130.75.131.208:8080] [,d1d8bf482db0af10] 2019-09-16 13:40:25.220 INFO 18088 [pool-1-thread-1] com.open.capacity.log.test.controller.TestController oook 复制代码
异步传递MDC
CompletableFuture 绑定自定义TaskExecutor
需要下沉到另外一个类
欢迎关注个人微信公众号: Coder编程 欢迎关注 Coder编程 公众号,主要分享数据结构与算法、Java相关知识体系、框架知识及原理、Spring全家桶、微服务项目实战、DevOps实践之路、每日一篇互联网大厂面试或笔试题以及PMP项目管理知识等。更多精彩内容正在路上~ 也分享一些杂文~
文章收录至 Github: github.com/CoderMerlin… Gitee: gitee.com/573059382/c… 欢迎 关注 并star~