英文:
Strange Log.i() behavior Android Studio
问题
我看到了一些非常奇怪的东西。我正在进行一个HTTP POST请求
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = null;
try {
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String strResponse = null;
if (entity != null) {
strResponse = EntityUtils.toString(entity);
Log.i("SetupAutoCardResponse",String.valueOf(strResponse));
Log.i("otherTest","test");
Log.i("otherTest",strResponse);
return true;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
日志中唯一的输出是 otherTest : Test
。
与 strResponse
相关的日志根本没有显示出来,我的意思是,什么都没有显示。它看起来不像是这样的 SetupAutoCardResponse : null
或者 otherTest: null
。绝对什么都没有显示出来。但我知道我收到了一个响应。表达式返回 true
。
英文:
I'm seeing something really weird. Im making a http post request
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = null;
try {
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String strResponse = null;
if (entity != null) {
strResponse = EntityUtils.toString(entity);
Log.i("SetupAutoCardResponse",String.valueOf(strResponse));
Log.i("otherTest","test");
Log.i("otherTest",strResponse);
return true;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
The only output I see in the log is otherTest : Test
.
The logs with strResponse
dont show up at all, and by that I mean, nothing shows. It does not look like this SetupAutoCardResponse : null
or otherTest: null
. Absolutly nothing shows up. But I know I am getting a response. The expression returns true
答案1
得分: 1
在日志中,如果消息为Null、空白或空,日志将不会记录。
示例:Log.i(TAG, MSG);
为了确保它起作用,我们可以向MSG添加一些文本。
Log.i(TAG, String.format("%s %s", "MSG>", MSG));
英文:
In Log, if the Messsage is Null or Blank or Empty, Log will not write down.
Example: Log.i(TAG, MSG);
To make sure it works, we can add some text to MSG
Log.i(TAG, String.format("%s %s", "MSG>" , MSG));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论