2017-12-15 18 views
0

sqlite 데이터베이스에 logcat 항목을 저장할 수 있습니까? 사용자가 오류가 발생하는 경우 전화기를 adb에 연결하지 않고 로그를 읽으려고합니다. SQLite 데이터베이스에 LogCat 항목 저장

내가 로그를 작성하는 방법입니다 : 오류를

public void mlogFile(String pActivityName, String pOperation, String pData) { 
     File lLogFilePath, lLogFile; 
     Date lDate; 
     CharSequence lCurrfolder; 
     FileWriter lFileWriter; 
     BufferedWriter lBuffWriter; 
     String lActivity, lOperation; 
     try { 
      lDate = new Date(); 
      lCurrfolder = DateFormat.format("yyyyMMdd", lDate.getTime()); 
      lLogFilePath = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "CSPDCLData/" + lCurrfolder + "/"); 
      if (!lLogFilePath.exists()) { 
       lLogFilePath.mkdirs(); 
      } 
      lLogFile = new File(lLogFilePath, "ADDLogfile.txt"); 
      lFileWriter = new FileWriter(lLogFile, true); 
      lBuffWriter = new BufferedWriter(lFileWriter); 
      lActivity = pActivityName.length() != 0 ? ADDPadding(pActivityName, 25, ' ', 'L') + "~ " : ""; 
      lOperation = pOperation.length() != 0 ? " : " + pData : ""; 
      lBuffWriter.append(DateFormat.format("kk:mm:ss", lDate.getTime()) + " " + lActivity + pOperation + lOperation + "\n"); 
      lBuffWriter.flush(); 
      lBuffWriter.close(); 
      lFileWriter.close(); 
     } catch (IOException ex) { 
      Toast.makeText(this, "ERROR: " + ex.getMessage(), Toast.LENGTH_SHORT).show(); 
     } 
    } 

을 읽고 더 나은 선택이 될 것입니다 로그 파일을 생성 Log.d(TAG, "An error occured", e)

감사

+0

왜 [오류보고 라이브러리] (https://fabric.io/kits/and)를 사용하지 않습니까? roid/crashlytics/summary) (게시하는 경우)? 관련 충돌 로그가있는 응용 프로그램이 손상되었을 때 메일을 보냅니다. –

+0

응용 프로그램을 중단하지 않고도 오류가 발생할 수 있습니다. –

+0

instabug https://instabug.com/을 사용할 수 있습니다. 크래시의 전체 내용을 제공합니다 –

답변

0

을 그리고 오류의 시간이 줄을 추가

logFile(getClass().getSimpleName(),"methodName()", "An error occured"+ e.getMessage()); 
+0

파일이 데이터베이스보다 나은 이유는 무엇입니까? –

+0

외부 저장소에서만 볼 수있는 데이터베이스를 사용할 필요가 없습니다. 어디서나 텍스트 파일로 볼 수 있습니다. –