如上图所示,我在运行 macaca 框架的时候,会输出大量的这种类型的 log,实在是影响查看关键信息,我查了下 macaca 代码,应该是在 System.out.println 输出的,想问下,这种 log 输出能否重新处理下,用 common-logging, slf4j 之类的来处理

public Object postRequest(String method, JSONObject jsonBody) throws Exception {
    JSONObject tempObj = new JSONObject();
    for (String key : jsonBody.keySet()) {
        String value = jsonBody.get(key).toString();
        if (method.contains(":" + key)) {
            method = method.replace(":" + key, value);
        } else {
            tempObj.put(key, jsonBody.get(key));
        }
    }

    try {
        String url = Constants.SUFFIX.replace("${host}", driver.getHost()).replace("${port}", driver.getPort()) + method;
        httppost = new HttpPost(url);
        if (jsonBody != null) {
            stringEntity = new StringEntity(tempObj.toString(), "utf-8");
            stringEntity.setContentEncoding("utf-8");
            stringEntity.setContentType("application/json");
            httppost.setEntity(stringEntity);
        }
        response = httpclient.execute(httppost);
        entity = response.getEntity();
        System.out.println(response.getStatusLine().getStatusCode());
        if (entity != null) {
            stringResponse = EntityUtils.toString(entity);
            System.out.println("Response content:" + stringResponse);
            jsonResponse = JSON.parseObject(stringResponse);
            handleStatus(jsonResponse.getInteger("status"));
            return jsonResponse;
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}


↙↙↙阅读原文可查看相关链接,并与作者交流