Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't turn off debug logging for Wiremock

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?

like image 982
James McMahon Avatar asked Jun 09 '17 14:06

James McMahon


People also ask

How do I change the port on my WireMock?

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.

How do I enable debug logs in spring boot?

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.


1 Answers

Ok Ive just had this problem and finally solved it. There are 3 different loggers you need to configure

  • the eclipse logger at wiremock.org.eclipse
  • the wiremock notifier at WireMock
  • the serverlet logger at "/" or what ever your logger is located at.
  • the wiremock code logging 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"/>
like image 92
Kevlar Avatar answered Oct 04 '22 17:10

Kevlar