2

AndroidのLog Catをtxtファイルに書き込む方法ですが、すべてのログは必要ありませんが、アプリ用のものだけが必要です。私はこのコードを持っていますが、すべてを書いています

 String fileName = "logcat.txt";
    File root = Environment.getExternalStorageDirectory();
     System.out.println("CONTEXT : " + root);
     File outputFile = new File(root.getAbsolutePath(), fileName);
     System.out.println("FILE : " + outputFile);
     @SuppressWarnings("unused")
        Process process;
        try {
            process = Runtime.getRuntime().exec("logcat -f "+ outputFile);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

自分だけのアプリを書くための作り方!アプリの名前は nick.app です

ありがとう

4

2 に答える 2

1

logcat の filter-spec パラメータを使用します。詳細は次のとおりです。

http://developer.android.com/tools/debugging/debugging-log.html#filteringOutput

例:

adb logcat -f /sdcard/logcat.txt MyApp:D *:S

これにより、DEBUG 最小レベル (MyApp:D) の MyApp タグからのログが表示され、他のすべてのログ (*:S) が抑制されます。

于 2013-05-21T10:44:39.960 に答える
0

maybe androlog (https://github.com/akquinet/androlog) could be an alternative? It's more versatile when it comes to logging and you can log to a file. Furthermore you can send reports about errors which is maybe what you are trying to accomplish in the end?

于 2013-05-20T21:05:04.310 に答える