【发布时间】:2015-06-04 01:59:28
【问题描述】:
我正在为 REST API 开发一个 JAVA 客户端。我正在为客户使用改造。我看到我可以在改造中创建适配器时设置日志级别。所有这些日志当前都进入控制台。但是,我想将此重定向到应用程序中已使用的 logback 生成的日志。我该怎么做?
RestAdapter restAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL).setEndpoint(APP_URL)
.setRequestInterceptor(new AuthRequestInterceptor())
.setErrorHandler(new RetrofitErrorHandler()).build();
输出
---> HTTP GET http://localhost:8080/services/v1/countries
Auth-Token: ...
---> END HTTP (no body)
<--- HTTP 200 http://localhost:8080/services/v1/countries (448ms)
Transfer-Encoding: chunked
: HTTP/1.1 200 OK
Vary: Accept-Encoding
Date: Thu, 04 Jun 2015 01:36:29 GMT
Content-Type: application/json
...
<--- END HTTP (9130-byte body)
我希望所有这些都进入记录器日志。
【问题讨论】:
标签: java logging slf4j logback retrofit