加特林-在Simulation.log或控制台中记录请求的正文 [英] Gatling - Log body of request in simulation.log or console
问题描述
我想看看我在脚本中发送的帖子的正文.实际上,我希望看到请求,请求正文和响应.通过查看文档和论坛,我发现可以取消对logback-test.xml中的一行的注释,如下所示
I would like to see what is in the body of the post that I am sending in my script. In fact, I would like to see the request, request body and response. From looking at the docs and the forums, I see that I can uncomment a line in logback-test.xml which I did as shown below
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
</appender>
<!-- Uncomment for logging ALL HTTP request and responses -->
<logger name="io.gatling.http" level="TRACE" />
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
<!--<logger name="io.gatling.http" level="DEBUG" /> -->
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
simulation.log文件或控制台都向我显示了请求,响应等.经过一些谷歌搜索和阅读文档后,我发现我可以做到这一点-
The simulation.log file nor the console shows me the request, response etc. After a bit of googling and reading documentation, I saw that I could do this -
.extraInfoExtractor(extraInfo => List(extraInfo.request, extraInfo.response,extraInfo.session))
这为我提供了除请求正文以外的几乎所有内容.如何获得请求正文?我正在尝试调试一个问题,在此问题上,我确定要发送的正文不是我真正想要的.
This provides me with pretty much everything except the request body. How do I get the request body? I am trying to debug an issue where I am sure the body that is getting sent is not what I actually want.
推荐答案
将此添加到您的logback.xml
Add this to your logback.xml
<logger name="io.gatling.http.ahc" level="DEBUG" />
这将为每个失败打印以下详细信息-
This will print following details for each failure -
- 请求网址
- 请求标头
- 请求正文
- 响应头
- 加特林会话数据
这篇关于加特林-在Simulation.log或控制台中记录请求的正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!