Skip to content
This repository was archived by the owner on Jul 7, 2026. It is now read-only.
This repository was archived by the owner on Jul 7, 2026. It is now read-only.

No logs from WireMockΒ #1916

Closed
Closed

Description

@bartoliniii

Hello!
I'm using the latest version of Spring Cloud Contract (4.0.3) with Spring Boot 3.1.0 with slf4j-api 2.0.7 with log4j 2.19.0.
I have a very simple stub runner run by annotation (@AutoConfigureStubRunner), with embedded wiremock run on random port and it works pretty well, but I can't see any logs from WireMock.

According to this article is should work out of the box, but it doesn't in my case.

I debugged a little and I found that the reason is that wiremock-jre8-standalone uses its own copy of slf4j classes prefixed with wiremock package (e.g. wiremock.org.slf4j.Logger) so my log configuration can't work with it and finally NOPLogger from wiremock.org.slf4j package is used.

I didn't find any way to make logger working. I even tried to replace wiremock-jre8-standalone and use a standard wiremock-jre8, but it is not possible - some classes e.g. HandlebarsTemplateProcessor uses repacked dependencies from standalone version of wiremock.

Did I miss something?
Is there any way to make it working?

Activity

  1. copbint commented on Jul 25, 2023

    @copbint

    I have come across this issue too, and can't find solution.

  2. marcingrzejszczak commented on Sep 4, 2023

    @marcingrzejszczak
    Contributor

    Do you have a small project that replicates this issue?

  3. tgeens commented on Sep 5, 2023

    @tgeens
    @SpringBootTest
    @AutoConfigureWireMock(port = 0)
    public class AutoConfigureWireMockApplicationTests {
    
        @Autowired
        WireMockServer wireMockServer;
    
        @Test
        public void testLogging() {
            wireMockServer.stubFor(get(urlEqualTo("/test"))
                    .willReturn(ok("Hello World!")));
    
            var result = WebClient.create()
                    .get().uri("http://localhost:{port}/test", wireMockServer.port())
                    .exchangeToMono(response -> response.bodyToMono(String.class))
                    .block();
    
            assertThat(result).isEqualTo("Hello World!");
        }
    }
    

    Trying this (in my webflux project) gives 0 wiremock logging.

    I tried setting logging.level.WireMock=DEBUG etc, but that gives the same result.

  4. tgeens commented on Sep 5, 2023

    @tgeens

    As a workaround, I switched to the ConsoleNotifier and this works as expected:

        @Bean
        WireMockConfigurationCustomizer optionsCustomizer() {
            return config -> config.notifier(new ConsoleNotifier(true));
        }
    

    That reduces the logging-problem to a slf4j/logback config issue? πŸ€”

  5. adamsmith118 commented on Sep 5, 2023

    @adamsmith118

    That reduces the logging-problem to a slf4j/logback config issue? πŸ€”

    Presumably it's defaulting NOPLogger, which wouldn't write anything...

  6. added a commit that references this issue on Sep 5, 2023
    44c634d
  7. added this to the 4.0.5 milestone on Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions