java - Logging Retrofit to Logback Logger -


i'm developing java client rest api. i'm using retrofit client. see can set log level when creating adapter in retrofit. log goes console. however, want redirect log generated logback used in application. how do ?

restadapter restadapter = new restadapter.builder()                 .setloglevel(restadapter.loglevel.full).setendpoint(app_url)                 .setrequestinterceptor(new authrequestinterceptor())                 .seterrorhandler(new retrofiterrorhandler()).build(); 

output

---> http 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) 

i want go logger log.

the restadapter.builder support passing log using setlog method. log interface. create own logback implementation of interface , pass builder when creating restadapter.

public class logbacklog implements log {      public void log(string message) {         // call logback logger here     } }  log logger = new logbacklog();  restadapter restadapter = new restadapter.builder()             .setlog(logger)             .setloglevel(restadapter.loglevel.full).setendpoint(app_url)             .setrequestinterceptor(new authrequestinterceptor())             .seterrorhandler(new retrofiterrorhandler()).build(); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -