0
我使用了REST自動化框架的球衣客戶v2.25.1這裏是怎麼了登記記錄器和初始化客戶端:Jersey客戶端2.25日誌不是請求/響應交通工作
//Initialize FileHandler
Path currPath = Paths.get(System.getProperty("user.dir"));
Path logFilePath = Paths.get(currPath.toString(), "logs", testCaseName+".log");
logHandleObj = new FileHandler(logFilePath.toString(), 0, 1, true);
//Initialize Logger
Logger loggerObj = Logger.getLogger(testCaseName);
loggerObj.setUseParentHandlers(false);
loggerObj.addHandler(logHandleObj);
//Initialize ClientConfig
ClientConfig clientConfig = new ClientConfig();
//Set configuration features
clientConfig.register(new JacksonFeature());
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
clientInstance = ClientBuilder.newClient(clientConfig);
//Register LoggingFeature
clientInstance.register(new LoggingFeature(loggerObj, Level.ALL,
LoggingFeature.Verbosity.PAYLOAD_ANY, LoggingFeature.DEFAULT_MAX_ENTITY_SIZE));
由於每documentation,這是應該記錄整個請求/響應流量,像這樣:
1 May 09, 2016 2:55:33 PM org.glassfish.jersey.logging.LoggingInterceptor log
2 INFO: 1 * Server has received a request on thread grizzly-http-server-0
3 1 > GET http://localhost:9998/helloworld
....
但是,我得到:
<?xml version="1.0" encoding="windows-1252" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2017-02-25T15:30:06</date>
<millis>1488016806253</millis>
<sequence>0</sequence>
<logger>org.glassfish.jersey.client.JerseyInvocation</logger>
<level>WARNING</level>
<class>org.glassfish.jersey.client.JerseyInvocation</class>
<method>validateHttpMethodAndEntity</method>
<thread>1</thread>
<message>Entity must not be null for http method PUT.</message>
</record>
個
所以兩個問題在這裏:
- 沒有得到HTTP流量
- 格式爲XML出於某種原因,而不是純文本
會很感激有這方面的援助。