Skip to content

Logging

CloudStub uses SLF4J as its logging facade. No logging implementation is bundled; you bring your own.

Default output (standalone mode)

In standalone mode the JAR ships slf4j-simple, which writes all log output to stdout. The default level is INFO.

Startup produces output similar to:

INFO CloudStub - CloudStub started on port 4566
INFO ModuleInitializer - Registered module: sqs (8 stub(s))
INFO ModuleInitializer - Registered module: sns (42 stub(s))
INFO ModuleInitializer - Registered module: secretsmanager (5 stub(s))
INFO ModuleInitializer - Registered module: s3 (107 stub(s))

Each matched request is logged at INFO:

INFO CloudStubResponseTransformer - sqs AmazonSQS.SendMessage -> 200

Fault-injected requests include a tag:

INFO CloudStubResponseTransformer - sqs AmazonSQS.SendMessage -> 400 [throttled]
INFO CloudStubResponseTransformer - sqs AmazonSQS.SendMessage -> 200 [timeout]

Unmatched requests are logged at WARN with the method, URL, X-Amz-Target, and Content-Type headers:

WARN CloudStubResponseTransformer - Unmatched request: POST / (X-Amz-Target: AmazonSQS.UnknownOp, Content-Type: application/x-amz-json-1.0)

Shutdown produces:

INFO CloudStub - CloudStub stopped

Log levels

Level What is logged
INFO Startup (port), shutdown, per-module registration with stub count, every matched request (service, operation, status code)
DEBUG Every stub registered by WireMockStubRegistrar; full request and response bodies for every matched request
WARN Every unmatched request (method, URL, X-Amz-Target, Content-Type)

Enable DEBUG logging

Standalone mode

Pass the cloudstub.debug system property or set the CLOUDSTUB_DEBUG environment variable before the first logger is acquired. Both promote the root level from INFO to DEBUG.

java -Dcloudstub.debug=true -jar cloudstub-local/build/libs/cloudstub-local.jar
CLOUDSTUB_DEBUG=true java -jar cloudstub-local/build/libs/cloudstub-local.jar

Embedded mode

Configure DEBUG on your own logging implementation. For Logback, add a logger entry to logback-test.xml:

<logger name="io.cloudstub" level="DEBUG"/>

Custom logging implementation

In standalone mode you can replace slf4j-simple with any SLF4J-compatible implementation by placing its JAR on the classpath ahead of the standalone JAR. In embedded mode, add your preferred implementation to your test dependencies; CloudStub will bind to it automatically.

Logback example (embedded / Spring Boot)

Add the dependency (Spring Boot users: already present via spring-boot-starter):

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <scope>test</scope>
</dependency>

Configure a logger in src/test/resources/logback-test.xml:

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <logger name="io.cloudstub" level="INFO"/>

  <root level="WARN">
    <appender-ref ref="STDOUT"/>
  </root>
</configuration>

Change level="INFO" to level="DEBUG" to capture stub registration and full request/response bodies.