logcat truncate long string

转载 2013年12月04日 17:30:35




$ adb logcat -g
ring buffer is 64Kb (63Kb consumed), max entry is 4096b, max payload is 4076b


As already mentioned, you can see the size of the circular buffer with logcat -g. On my Galaxy Nexus, it's 256 KB:

shell@android:/ $ logcat -g
/dev/log/main: ring buffer is 256Kb (255Kb consumed), max entry is 4096b, max payload is 4076b
/dev/log/system: ring buffer is 256Kb (0Kb consumed), max entry is 4096b, max payload is 4076b

If you need to save a continuous log longer than that, you can just open a new adb shell and type

logcat -f myfile.log

This command redirects log entries to the file myfile.log on an ongoing basis, and won't return until you hit ctrl-c to stop it. Now go back to your original adb shell and type the command you wanted to log, and all its output (more than 256 KB in my case) will get saved to myfile.log.













1 down vote accepted

Because your logcat has reached its max size, see What is the size limit for Logcat?
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();
    }
}





















for( String line : logMesg.split("\n") ) {
    Log.d( TAG, line );
}

Date4long2String

  • 2015年10月10日 17:35
  • 3KB
  • 下载

JAVA中switch能否用在byte上?能否用在long上?能否用在string上?

不知道你所说的表达式是什么意思。你可以声明一个Long型变量并初始化。如: Long i;或Long i = 10L; 至于在switch语句中为什么不能使用Long型变量,java中有这样的规定...

Android:Date、String、Long三种日期类型之间的相互转换

date类型转换为String类型 // formatType格式为yyyy-MM-dd HH:mm:ss//yyyy年MM月dd日 HH时mm分ss秒 // data Date类型的时...

java Data、String、Long三种日期类型之间的相互转换

以前做项目没遇到时间 、字符串、long型的三者之间的转化,最多也就两两转化,现在项目遇到了这么一个情况,感觉比较麻烦,但是呢再麻烦也得完成不,谁叫咱是苦逼的程序猿呢,经过百度加实践发现了他们之间互相...

Java,bit比特,byte字节,char字符,short,int,long,float,double,string,字母,汉字/编码等

如题,做个重新认识的总结,只供参考,如果不准确的,请回复,谢谢 bit: 1 bit = 1 二进制数据 byte: 1 byte = 8 bit 字母: 1 字母 = 1 byte = 8 bi...

js将时间由long类型转换为string类型

前面写到过 jqGrid自带了转换时间的工作,后台只需返回long类型的时间即可正常显示。 {name : "time",width:128,fixed:true,label : ...

SharedPreferences类供开发人员保存和获取基本数据类型的键值对.该类主要用于基本类型, 例如boolean,float.int,long和string. SharedPr

转载自http://blog.csdn.net/wenzhi20102321/article/details/53065311 SharedPreferences类供开发人员保存和获取基本数据类...

java、MySQL时间类型的转换及存储(Timestamp、Date、String、Long)

[java] view plain copy import java.sql.Connection;   import java.sql.PreparedStateme...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:logcat truncate long string
举报原因:
原因补充:

(最多只允许输入30个字)