#鸿蒙学习大百科#应用发生故障时如何获取系统日志?

应用发生故障时如何获取系统日志?

HarmonyOS
2024-10-26 10:32:48
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
海底捞天王
import { FaultLogger } from '@kit.LancetKit';
import { BusinessError } from '@kit.BasicServicesKit';

function queryFaultLogCallback(error: BusinessError, value: Array<FaultLogger.FaultLogInfo>) {
  if (error) {
    console.info('error is ' + error);
  } else {
    console.info("value length is " + value.length);
    let len: number = value.length;
    for (let i = 0; i < len; i++) {
      console.info("log: " + i);
      console.info("Log pid: " + value[i].pid);
      console.info("Log uid: " + value[i].uid);
      console.info("Log type: " + value[i].type);
      console.info("Log timestamp: " + value[i].timestamp);
      console.info("Log reason: " + value[i].reason);
      console.info("Log module: " + value[i].module);
      console.info("Log summary: " + value[i].summary);
      console.info("Log text: " + value[i].fullLog);
    }
  }
}

try {
  FaultLogger.query(FaultLogger.FaultType.JS_CRASH, queryFaultLogCallback);
} catch (err) {
  console.error(`code: ${(err as BusinessError).code}, message: ${(err as BusinessError).message}`);
}
分享
微博
QQ
微信
回复
2024-10-26 16:29:06
相关问题
#鸿蒙学习大百科#什么是应用沙箱?
336浏览 • 1回复 待解决