quarkiverse / quarkus-wiremock

Quarkus extension for launching an in-process Wiremock server
https://wiremock.org/
Apache License 2.0
16 stars 12 forks source link

Ability to configure logging for WireMock #160

Closed diversit closed 4 weeks ago

diversit commented 2 months ago

Would it be possible to somehow configure the logging of WireMock? Every now and then I'm struggling with why WireMock is returning a 404 instead of the configured stub. Having some kind of logging what WireMock is receiving and sending would be very helpful.

WireMock seems to support 2 ways to capture the request/response or do logging

  1. Set a Notifier in the WireMockConfiguration
  2. Register a RequestListener on the WireMockServer instance.

Both cannot be set from a QuarkusTest since these are no methods on a WireMock instance and the WireMockServer is created by the WireMockServerProcessor of this extension.

Unfortunately, the default Notifier is set to a Slf4jNotifier but with a verbose=false setting causing nothing to be logged.

Also, there is an issue with the Slf4j logging (issue 2557) which causes the Slf4jNotifier always to have a NOPLogger so nothing will be logged anyway. A proposed solution is to remove Slf4j and use Java Logging instead (PR 2616). But there also the verbose=false in the default configuration, so still nothing would be logged.

Would it be possible to configure a Notifier or RequestListener via the WireMockServerBuildTimeConfig or can the configuration only use simple types like boolean, int, String, etc? If there is a way, please point me in the right direction and I'm happy to create a PR for this.

chberger commented 1 month ago

Hi @diversit, @derari submitted PR #142 that implements the capabilities you requested, following your suggested solution #1. I've documented the feature and merged it into version 1.4.0. Would you like to give it a try?

chberger commented 1 month ago

@all-contributors add @derari for code

allcontributors[bot] commented 1 month ago

@chberger

I've put up a pull request to add @derari! :tada:

diversit commented 4 weeks ago

Tested wiremock logging with version 1.4.0. Works great! Thanks!