2011-04-19 45 views

回答

0

我最終編寫了自己的函數來登錄設備。

public static BufferedWriter out; 
    private void createFileOnDevice(Boolean append) throws IOException { 
      /* 
      * Function to initially create the log file and it also writes the time of creation to file. 
      */ 
      File Root = Environment.getExternalStorageDirectory(); 
      if(Root.canWrite()){ 
       File LogFile = new File(Root, "Log.txt"); 
       FileWriter LogWriter = new FileWriter(LogFile, append); 
       out = new BufferedWriter(LogWriter); 
       Date date = new Date(); 
       out.write("Logged at" + String.valueOf(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "\n")); 
      } 
     } 

public void writeToFile(String message){ 
     try { 
      out.write(message+"\n"); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

SO的相關問題是here

0

Logcollector是您的選擇,但您需要首先在您的設備上安裝它。

同樣可以通過ADB

運行adb shell logcat > your_log_file.txt從命令提示符保存活動日誌。

+0

謝謝。該應用程序用於讀取WiFi信號和錄製強度,因此我無法在工作時將其連接到系統。關於Logcollector,有沒有辦法將日誌存儲爲文件,後者是通過訪問而不是郵件/短信? – primpap 2011-04-19 09:58:25

+0

然後,您必須創建您自己的日誌收集器方法,或者您可以嘗試更改LogCollector的代碼。您可以嘗試的另一種方法是將日誌保存在sqllite數據數據庫中,然後嘗試稍後閱讀它們。 – 2011-04-19 10:06:33

相關問題