0
votes

how can I enable http logs in camel? I'm using rest-dsl. I would like to see http headers and bodies for every request and response My code:

restConfiguration()
                .component("jetty")
                .host("0.0.0.0")
                .port(port)
                .scheme("https")
                .bindingMode(RestBindingMode.json)
                .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES")
                .dataFormatProperty("json.in.enableFeatures", "FAIL_ON_NULL_FOR_PRIMITIVES")
                .componentProperty("sslKeyPassword", KEYSTORE_PASSWORD)
                .componentProperty("sslKeystore", KEYSTORE)
                .componentProperty("sslPassword", KEYSTORE_PASSWORD)
                .enableCORS(true)
                .componentProperty("traceEnabled", "true")
                // swagger
                .apiContextPath("api-doc")
            .apiProperty("api.title", "Mobile Api").apiProperty("api.version", "v1.0")
            .apiProperty("schemes", "https")
           ;

and

rest(MOBILE_API_PATH).produces("application/json").consumes("application/json")

            .post("/transaction").type(MobileTransactionRequest.class).outType(MobileTransactionResponse.class)
            .to("direct:mobileTransaction")
1

1 Answers

1
votes

To enable component logging you'll need to create this beans :

<bean id="log" class="org.eclipse.jetty.server.handler.RequestLogHandler">
    <property name="requestLog" ref="jettyLog"/>
</bean>
<bean id="jettyLog" class="org.eclipse.jetty.server.Slf4jRequestLog"/>

And configure enpoint like this:

jetty:http://0.0.0.0:8040/test?handlers=#log

But by default logger will not write body and all headers. You should create your class extending AbstractLifeCycle and implementing RequestLog, with own log logic.