springboot启动器printparam

 

springboot启动器,自动在日志中打印输入输出参数,快捷方便,无需任何配置项,依赖少,开箱即用。

无中文乱码,可设置拦截路径和排除路径,可配置是否打印输入和输出。可以用于测试和开发环境排除bug查找问题。也可以直接用于生产环境记录请求。

使用方法:

1.clone代码到本地

 

[AppleScript]  纯文本查看  复制代码
?
1
< font style = "color:rgb(61, 70, 77)" > < font face = "&quot;" > < font style = "font-size:16px" > git clone [ url = mailto : [email protected]][email protected][ / url ] : sjlian / printparam - spring - boot - starter.git < / font > < / font > < / font >

 

2.安装到本地maven库,cd 到项目目录下

 

[AppleScript]  纯文本查看  复制代码
?
1
2
< font style = "color:rgb(61, 70, 77)" > < font face = "&quot;" > < font style = "font-size:16px" > cd printparam - spring - boot - starter
maven install < / font > < / font > < / font >

 

3.引入到springboot项目依赖。

 

[AppleScript]  纯文本查看  复制代码
?
1
2
3
4
5
< font style = "color:rgb(61, 70, 77)" > < font face = "&quot;" > < font style = "font-size:16px" > < dependency >
            < groupId > com.github.printparam < / groupId >
            < artifactId > printparam - spring - boot - starter < / artifactId >
            < version > 0.0 . 1 - SNAPSHOT < / version >
       < / dependency > < / font > < / font > < / font >

 

4.可选,配置参数

 

[AppleScript]  纯文本查看  复制代码
?
1
2
3
4
< font style = "color:rgb(61, 70, 77)" > < font face = "&quot;" > < font style = "font-size:16px" > print - param.enableInputParam = true 是否在日志中打印输入信息,默认 true
print - param.enableOutputResult = false  是否在日志中打印输出信息,默认 false
print - param.filterIncludePattern = / *  拦截哪些 url 进行日志打印 默认 / * 表示全部拦截,正则表达式 , 建议只拦截接口访问数据如 / api / *
print - param.filterExcludePattern = ( / webjars / . * | / css / . * | / images / . * | / fonts / . * | / js / . * )  正则表达式描述不拦截哪些 url 打印日志,默认如左 < / font > < / font > < / font >

 

5.日志输入格式如下:

 

[AppleScript]  纯文本查看  复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
< font style = "color:rgb(61, 70, 77)" > < font face = "&quot;" > < font style = "font-size:16px" deep = "22" > 对于request:
     uri表示请求接口
     header表示请求头
     form是表单数据
     body是json数据
对于response:
     return data 表示返回数据
     
request uri : / api / user 1 / add
request header : { Origin = http : / / localhost : 8081 , Accept = * / * , Connection = keep - alive , User - Agent = Mozilla / 5.0 ( Macintosh; Intel Mac OS X 10 _ 14 _ 2 ) AppleWebKit / 537.3 6 ( KHTML , like Gecko ) Chrome / 71.0 . 3578.9 8 Safari / 537.3 6 , Referer = http : / / localhost : 8081 / api / swagger - ui.html , Host = localhost : 8081 , Accept - Encoding = gzip , deflate , br , Accept - Language = zh - CN , zh;q = 0.9 , Content - Length = 34 , Content - Type = application / json }
request form : { }
request body : {  "age" : 26 ,  "name" : "hello" }
response return data : { "code" : 0 , "message" : "success" , "url" : null , "data" : { "id" : null , "name" : "hello" , "age" : 26 , "version" : null } }
request uri : / api / user 1 / add
request header : { Origin = http : / / localhost : 8081 , Accept = * / * , Connection = keep - alive , User - Agent = Mozilla / 5.0 ( Macintosh; Intel Mac OS X 10 _ 14 _ 2 ) AppleWebKit / 537.3 6 ( KHTML , like Gecko ) Chrome / 71.0 . 3578.9 8 Safari / 537.3 6 , Referer = http : / / localhost : 8081 / api / swagger - ui.html , Host = localhost : 8081 , Accept - Encoding = gzip , deflate , br , Accept - Language = zh - CN , zh;q = 0.9 , Content - Length = 35 , Content - Type = application / json }
request form : { }
request body : {  "age" : 16 ,  "name" : "张三" }
response return data : { "code" : 0 , "message" : "success" , "url" : null , "data" : { "id" : null , "name" : "张三" , "age" : 16 , "version" : null } }
request uri : / api / user 1 / get / 1
request header : { Accept = * / * , Connection = keep - alive , User - Agent = Mozilla / 5.0 ( Macintosh; Intel Mac OS X 10 _ 14 _ 2 ) AppleWebKit / 537.3 6 ( KHTML , like Gecko ) Chrome / 71.0 . 3578.9 8 Safari / 537.3 6 , Referer = http : / / localhost : 8081 / api / swagger - ui.html , Host = localhost : 8081 , Accept - Encoding = gzip , deflate , br , Accept - Language = zh - CN , zh;q = 0.9 }
request form : { }
request body :
response return data : { "code" : 0 , "message" : "success" , "url" : null , "data" : null }
request uri : / api / user 1 / list
request header : { Accept = * / * , Connection = keep - alive , User - Agent = Mozilla / 5.0 ( Macintosh; Intel Mac OS X 10 _ 14 _ 2 ) AppleWebKit / 537.3 6 ( KHTML , like Gecko ) Chrome / 71.0 . 3578.9 8 Safari / 537.3 6 , Referer = http : / / localhost : 8081 / api / swagger - ui.html , Host = localhost : 8081 , Accept - Encoding = gzip , deflate , br , Accept - Language = zh - CN , zh;q = 0.9 }
request form : { }
request body :
response return data : { "code" : 0 , "message" : "success" , "url" : null , "data" : [] }
request uri : / api / demo / getHello
request header : { Accept = * / * , Connection = keep - alive , User - Agent = Mozilla / 5.0 ( Macintosh; Intel Mac OS X 10 _ 14 _ 2 ) AppleWebKit / 537.3 6 ( KHTML , like Gecko ) Chrome / 71.0 . 3578.9 8 Safari / 537.3 6 , Referer = http : / / localhost : 8081 / api / swagger - ui.html , Host = localhost : 8081 , Accept - Encoding = gzip , deflate , br , Accept - Language = zh - CN , zh;q = 0.9 }
request form : { }
request body :
response return data : hello < / font > < / font > < / font >

 

发布了946 篇原创文章 · 获赞 9 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/heima201907/article/details/105286372