Android: How to capture or redirect the logs from

2020-03-24 04:56发布

In Android, How to capture or redirect the logs from LogCat to a file using ECLIPSE IDE. I dont want to use command prompt option. As i haven't configured it . Thanks

3条回答
一纸荒年 Trace。
2楼-- · 2020-03-24 05:55

In the logcat view, to the right of the 'delete log' icon, is a pulldown (View menu), it brings up:

enter image description here

You can select the portion of log that you want, then use the "Export selection as text" option

查看更多
beautiful°
3楼-- · 2020-03-24 05:58

See logcat | Android Developers.

Can be redirected to file from the command prompt. Use adb logcat -f <filename>, or in Linux it will be better adb logcat | tee <filename>.

Also, you can capture the time stamp as well with adb logcat -v time -f <filename>, or in Linux it will be adb logcat -v time | tee <filename>.

查看更多
男人必须洒脱
4楼-- · 2020-03-24 05:59

use freopen to redirect stdout and stderr

the native code below works for me.

// cachedir is get from java code 'Context.getExternalCacheDir().getAbsolutePath()'
auto fullpath = cachedir + "/log";  
freopen(fullpath.c_str(),"w",stderr);

std::cerr << "hello, world\n";  // will write to file located at external storage
查看更多
登录 后发表回答