LogUtils
LogUtils copied to clipboard
日志文件内容刷新延迟
LogUtils.getLog2FileConfig().configLog2FilePath("/sdcard/logs").
configLog2FileEnable(true).
configLogFileEngine(new LogFileEngineFactory(this));
Intent intent = new Intent(this, MainActivity.class);
LogUtils.e(intent);
以上是我的代码,运行完之后再logcat正常输出了。去查看日志文件,文本文件为空,大概过了三分钟之后,日志文件里面才有这个数据
这是 mmap 的机制,不会即时写入文件,这也是性能比较好的主要原因。如果希望立即写入,可以主动调用 flush,或者杀进程重启也会马上写入
在adb logcat >a.log里 显示为乱码是不是也是这个原因
12-02 18:38:51.377 14075 14075 E LogUtils鉃? 鈺熲攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€ 12-02 18:38:51.377 14075 14075 E LogUtils鉃? 鈺?test-start app4 24