2011-09-07 63 views
2

我试图在twitter4j中测试一个简单的搜索方法。我的代码是如何在使用twitter4j时禁用打印请求信息

public void searchTweets(Query searchQuery) { 
    QueryResult queryResult = null; 

    try { 
     queryResult = twitter.search(searchQuery); 
    } catch (TwitterException e) { 
     log.error("Unable to search query = {}", searchQuery, e); 
    } 
} 

当我测试上面的代码,我得到以下输出。我应该如何禁用包含请求信息的输出?

- Request: 
- GET http://search.twitter.com/search.json?q=Sports&since_id=111374710708768768 

- OAuth base string: GET&http%3A%2F%2Fsearch.twitter.com%2Fsearch.json&oauth_con 
sumer_key%3DABk1pJ6bd5LWcf1lsIa9g%26oauth_nonce%3D914173077%26oauth_signature_me 
thod%3DHMAC-SHA1%26oauth_timestamp%3D1315388678%26oauth_token%3D73081379-KQOkj6E 
g4uBdUXSzlpvbtdb5OWOLXD3mxVo9nrdRV%26oauth_version%3D1.0%26q%3DSports%26since_id 
%3D111374710708768768 
- OAuth signature: oUszlR4fGxq8JiqXNFf+t6SgXdA= 
- Authorization: *************************************************************** 
******************************************************************************** 
******************************************************************************** 
************************************************* 
- X-Twitter-Client-URL: http://twitter4j.org/en/twitter4j-2.2.5-SNAPSHOT(build: 
5f9c44cd0e0c1972f8d17653a226b9b6a3392ac2).xml 
- X-Twitter-Client: Twitter4J 
- Accept-Encoding: gzip 
- User-Agent: twitter4j http://twitter4j.org/ /2.2.5-SNAPSHOT(build: 5f9c44cd0e0 
c1972f8d17653a226b9b6a3392ac2) 
- X-Twitter-Client-Version: 2.2.5-SNAPSHOT(build: 5f9c44cd0e0c1972f8d17653a226b9 
b6a3392ac2) 
- Response: 
- HTTP/1.1 200 OK 
- Age: 0 
- Content-Length: 1107 
- Expires: Wed, 07 Sep 2011 09:51:30 GMT 
- Connection: close 
- Server: hi 
- Cache-Control: max-age=15, must-revalidate, max-age=300 
- X-Varnish: 513089989 
- Vary: Accept-Encoding 
- Date: Wed, 07 Sep 2011 09:46:30 GMT 
- Content-Encoding: gzip 
- Via: 1.1 varnish 
- Content-Type: application/json;charset=utf-8 

- text='Montague Action Cricket: Titans 8 be at Forfeit +10 (10 - 1) http://t.co/2RbMzpK' 

回答

1

一下添加到log4j.properties:log4j.logger.twitter4j.internal.http=warn

+0

嗨Bozho!添加上面的行后..我得到相同的请求信息。我们正在使用twitter4j 4.0.2版本。如何禁用请求信息?请让我知道... – SST

+0

检查包装结构是否没有改变。 – Bozho