English 中文(简体)
春数据R2DBC中的立点参数的计分值?
原标题:Log values of query parameters in Spring Data R2DBC?
最佳回答
问题回答

对头2,也许其他行将尝试:

logging.level.io.r2dbc.h2=TRACE

在PopBoot诉2.7.5案中,

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

如果你会使用MySQL,那么通过将驾驶员的标识水平设定为<代码>,你可以把与数据库服务器的所有通信放在低水平的网络上。 TRACE。

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

例产出:

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                            |.......         |
+--------+-------------------------------------------------+----------------+

i have to update source code to log parameterize sql statement in mysql r2dbc . this is my approach :

  Index: src/main/java/dev/miku/r2dbc/mysql/message/client/TextQueryMessage.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/dev/miku/r2dbc/mysql/message/client/TextQueryMessage.java b/src/main/java/dev/miku/r2dbc/mysql/message/client/TextQueryMessage.java
--- a/src/main/java/dev/miku/r2dbc/mysql/message/client/TextQueryMessage.java   (revision bdba9eebe79976aa4bb75aa0aad25c7cbbdf4dec)
+++ b/src/main/java/dev/miku/r2dbc/mysql/message/client/TextQueryMessage.java   (revision 1b5e0133cc8d43bfc32133912d9e3589374ae75a)
@@ -20,6 +20,8 @@
 import dev.miku.r2dbc.mysql.Parameter;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufAllocator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import reactor.core.publisher.Mono;
 
 import java.nio.charset.Charset;
@@ -42,6 +44,8 @@
 
     private final Consumer<String> sqlProceed;
 
+    private static final Logger logger = LoggerFactory.getLogger(TextQueryMessage.class);
+
     public TextQueryMessage(List<String> sqlParts, Parameter[] values, Consumer<String> sqlProceed) {
         requireNonNull(sqlParts, "sql parts must not be null");
         requireNonNull(values, "values must not be null");
@@ -64,6 +68,10 @@
         try {
             Charset charset = context.getClientCollation().getCharset();
             return ParamWriter.publish(sqlParts, values).map(sql -> {
+
+                if(logger.isDebugEnabled()){
+                    logger.debug("parametered sql statement[{}]",sql);
+                }
                 sqlProceed.accept(sql);
 
                 ByteBuf buf = allocator.buffer(sql.length(), Integer.MAX_VALUE);

从而改变沉淀物中的原样质量:

<logger name="dev.miku.r2dbc.mysql.message.client.TextQueryMessage" level="DEBUG" additivity="false">
    <appender-ref ref="async_file"/>
</logger>




相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签