I'm using Wiremock for my tests in a Spring Boot app. I can't seem to get the logging to not output all debug logs, which makes my test runs very verbose.
I see it use SLF4J on startup:
DEBUG wiremock.org.eclipse.jetty.util.log - Logging to Logger[wiremock.org.eclipse.jetty.util.log] via wiremock.org.eclipse.jetty.util.log.Slf4jLog
But trying to configure it in my application.properties via,
logging.level.wiremock.org.eclipse=WARN
Has no effect, I've also setup
logging.level.com.github.tomakehurst.wiremock=WARN
But again, no effect. Since I'm using spring-boot-starter-web
which uses spring-boot-starter-logging
, which if I understand correctly uses Logback, I've also tried configuring this in logback-spring.xml
,
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="wiremock.org.eclipse" level="INFO"/>
</configuration>
Again, nothing I do stops Wiremock from logging debug level. What am I missing?
You have to set the WireMock port to 0 so that it chooses a random port and then use a reference to this port ( wiremock. server. port ) as part of the endpoint property. @RunWith(SpringRunner.
You can enable debug logging by specifying --debug when starting the application from the command-line. Spring Boot provides also a nice starting point for logback to configure some defaults, coloring etc. the base. xml file which you can simply include in your logback.
Ok Ive just had this problem and finally solved it. There are 3 different loggers you need to configure
wiremock.org.eclipse
WireMock
"/"
or what ever your logger is located at.com.github.tomakehurst.wiremock
Ive found that the bootstrap.yml does not affect these loggers so you need to put them in your logback-test.xml
in your /src/test/resources folder
with the following entries.
<!-- Turning down the wiremock logging -->
<logger name="com.github.tomakehurst.wiremock" level="WARN"/>
<logger name="wiremock.org" level="ERROR"/>
<logger name="WireMock" level="WARN"/>
<!-- wiremock has per endpoint servlet logging -->
<logger name="/" level="WARN"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With