Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn on tracing in a unit test using a ResourceTestRule?

Tags:

dropwizard

I'm using dropwizard with jersey. I'm having a problem with the path in a resource and would like to debug it. How do you configure the jersey environment variable for this? The following does not work.

@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(UserResource.class)
    .addProperty("jersey.config.server.tracing.type", "ON")
    .build();
like image 721
Mark Lilback Avatar asked Jul 30 '15 17:07

Mark Lilback


1 Answers

The following call in ResourceTestRule sets up the default logging with WARN level:

static {
    BootstrapLogging.bootstrap();
}

To override, I call BootstrapLogging again and indicate the required logging level in my test class after the ResourceTestRule creation, e.g.:

import ch.qos.logback.classic.Level;
import io.dropwizard.logging.BootstrapLogging;
...

@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(UserResource.class)
    .build();

static {
    BootstrapLogging.bootstrap(Level.DEBUG);
}

Then I can see my logging output in the console.

like image 80
andrius.velykis Avatar answered Oct 23 '22 10:10

andrius.velykis