Why does LogCat not show the full message?

后端 未结 2 1249
野的像风
野的像风 2020-12-20 06:47

Anyone knows why Logcat doesn\'t show full message? I try to print xml response from my site but I only can get some of it..

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 07:29

    Because your logcat has reached its max size, see What is the size limit for Logcat and how to change its capacity?
    Try using this code to write your result into a text file in sdcard, then use DDMS to get it.

     public static void appendLog(String text)
    {
        File logFile = new File("sdcard/log.txt");
        if (!logFile.exists())
        {
            try
            {
                logFile.createNewFile();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        try
        {
            // BufferedWriter for performance, true to set append to file flag
            BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
            buf.append(text);
            buf.newLine();
            buf.close();
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }
    

提交回复
热议问题