Log values of query parameters in Spring Data R2DBC?

廉价感情. 提交于 2021-02-20 16:15:25

问题


In Spring Data R2DBC I can log SQL queries by using

logging.level.org.springframework.data.r2dbc=DEBUG

in the application.properties.

However, this doesn't log the actual values that are bound as query parameters.

How can I log the actual values of query parameters in Spring Data R2DBC?


回答1:


This worked for me :

 logging:
  level:
    io.r2dbc.postgresql.QUERY: DEBUG # for queries
    io.r2dbc.postgresql.PARAM: DEBUG # for parameters

I found it here




回答2:


If you happen to use MySQL, you can get a low level network dump of all communication with the database server by setting the driver's log level to TRACE.

logging.level.ROOT=TRACE
logging.level.dev.miku.r2dbc.mysql.client.ReactorNettyClient=TRACE

Example output:

19-11-2020 00:03:28.072 TRACE [reactor-tcp-nio-2] d.m.r.mysql.client.ReactorNettyClient - [id: 0x9cf29125, L:/127.0.0.1:63807 - R:localhost/127.0.0.1:33306] READ: 71B
         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 01 00 00 01 01 1b 00 00 02 03 64 65 66 00 00 00 |..........def...|
|00000010| 05 4e 4f 57 28 29 00 0c 3f 00 13 00 00 00 0c 81 |.NOW()..?.......|
|00000020| 00 00 00 00 14 00 00 03 13 32 30 32 30 2d 31 31 |.........2020-11|
|00000030| 2d 31 39 20 30 31 3a 30 33 3a 32 38 07 00 00 04 |-19 01:03:28....|
|00000040| fe 00 00 02 00 00 00                            |.......         |
+--------+-------------------------------------------------+----------------+


来源:https://stackoverflow.com/questions/60972914/log-values-of-query-parameters-in-spring-data-r2dbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!