Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android集成xlog遇到一点问题,请教下 #23

Closed
AaronHezq opened this issue Dec 29, 2016 · 6 comments
Closed

Android集成xlog遇到一点问题,请教下 #23

AaronHezq opened this issue Dec 29, 2016 · 6 comments

Comments

@AaronHezq
Copy link

在测试xlog模块的时候获得的日志没有logcat中的全面,并且看不到crash的信息,是不是哪里配置的不对。
现象:
第一次点击按钮闪退,没有生成.xlog文件,log目录下只生成了MarsTest.mmap2,再次运行app才出现MarsTest_20161229.xlog;
集成信息:
依赖 compile 'com.tencent.mars:mars-xlog:1.0.0'
Application中的代码
@OverRide
public void onCreate() {
super.onCreate();
System.loadLibrary("stlport_shared");
System.loadLibrary("marsxlog");
initXlog();
}

private void initXlog() {
    final String SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
    final String logPath = SDCARD + "/marstest/log";
    //init xlog
    if (BuildConfig.DEBUG) {
        Xlog.appenderOpen(Xlog.LEVEL_DEBUG, Xlog.AppednerModeAsync, "", logPath, "MarsTest");
        Xlog.setConsoleLogOpen(true);
    } else {
        Xlog.appenderOpen(Xlog.LEVEL_INFO, Xlog.AppednerModeAsync, "", logPath, "MarsTest");
        Xlog.setConsoleLogOpen(false);
    }
    Log.setLogImp(new Xlog());
    Log.d(TAG, "已初始化xlog");
}
@Override
public void onTerminate() {
    super.onTerminate();
    Log.appenderClose();
}

测试时手动点击按钮抛出一个未捕获的空指针,logcat有输出
解密后的日志:$ python decode_mars_log_file.py MarsTest_20161229.xlog out.txt

^^^^^^^^^^Dec 28 2016^^^17:29:33^^^^^^^^^^[27946,27946][2016-12-29 +0800 12:59:15]
del time out files time: 0
get mmap time: 7
MARS_URL: 
MARS_PATH: hotfix/1.x
MARS_REVISION: 10b8355
MARS_BUILD_TIME: 2016-12-28 17:29:12
MARS_BUILD_JOB: mars_xlog_sdk/mars_libs
log appender mode:0, use mmap:1
[D][2016-12-29 +8.0 12:59:15.227][27946, 1*][App][, , 0][已初始化xlog
~~~~~ end of mmap ~~~~~[28549,28549][2016-12-29 +0800 13:00:04]
@shockcao
Copy link
Contributor

shockcao commented Dec 29, 2016

mmap2 是中间文件 xlog是通过写mmap,由操作系统将mmap中的内容flush到文件中

使用的android系统是什么版本? 是否有申请android WRITE_EXTERN权限,因为xlog需要创建文件,6.0以上需要动态申请权限

@AaronHezq
Copy link
Author

安卓版本 5.1.1 权限加了的,并且再次运行app会生成.xlog文件,但.xlog中的日志没包含logcat中的NullPointerException信息,是不是我哪里配置错了或者少加了东西,依赖只加了com.tencent.mars:mars-xlog:1.0.0

@garryyan
Copy link
Collaborator

xlog 不会去主动抓取 logcat 的日志,可以看到我们也没要求读取 logcat 的权限。 你如果想把 crash 的堆栈写到 xlog 里,需要你捕捉到后调用写 xlog 的日志接口。 xlog 的防止丢日志的机制是:假设你这次应用闪退了,会丢一部分日志,下次重启会找回。如果不重启是不会找回的。

@AaronHezq
Copy link
Author

理解了,谢谢

@congmf
Copy link

congmf commented Dec 30, 2016

请教一下xlog怎么在windows上打开

@garryyan
Copy link
Collaborator

@congmf #16 1.2将会支持

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants