如何在驼峰中启用http日志?我正在使用rest-dsl。我希望看到每个请求和响应的http标头和主体我的代码:
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")
;
和
rest(MOBILE_API_PATH).produces("application/json").consumes("application/json")
.post("/transaction").type(MobileTransactionRequest.class).outType(MobileTransactionResponse.class)
.to("direct:mobileTransaction")
答案 0 :(得分:1)
要启用组件日志记录,您需要创建此bean:
<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"/>
并像这样配置enpoint:
jetty:http://0.0.0.0:8040/test?handlers=#log
但默认情况下,记录器不会写入正文和所有标题。您应该创建扩展AbstractLifeCycle并使用自己的日志逻辑实现RequestLog的类。