springboot啓動器printparam

springboot啓動器,自動在日誌中打印輸入輸出參數,快捷方便,無需任何配置項,依賴少,開箱即用。css

無中文亂碼,可設置攔截路徑和排除路徑,可配置是否打印輸入和輸出。能夠用於測試和開發環境排除bug查找問題。也能夠直接用於生產環境記錄請求。
使用方法:html

1.clone代碼到本地git

 

[AppleScript] 純文本查看 複製代碼
?
1
<font style="color:rgb(61, 70, 77)"><font face="&quot;"><font style="font-size:16px">git clone [url=mailto:git@gitee.com]git@gitee.com[/url]:sjlian/printparam-spring-boot-starter.git</font></font></font>
 github

2.安裝到本地maven庫,cd 到項目目錄下web

 

[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項目依賴。spring

 

[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>
 json

4.可選,配置參數api

 

[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>
 springboot

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/user1/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.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36, 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/user1/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.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36, 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/user1/get/1
request header:{Accept=/, Connection=keep-alive, User-Agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36, 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/user1/list
request header:{Accept=/, Connection=keep-alive, User-Agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36, 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.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36, 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>

相關文章
相關標籤/搜索