I've added debug strings (using Log.d()) and want to see them in context from the contents of logCat. The "save" icon for LogCat has a "Save selected items" hint, but there's got to be a quick way to just save the entire contents, or select the entire contents, but I don't see how to do it.
11 Answers
To save the Log cat content to the file, you need to redirect to the android sdk's platform tools folder and hit the below command
adb logcat > logcat.txt
In Android Studio, version 3.6RC1, file will be created of the name "logcat.txt" in respective project folder. you can change the name according to your interest. enjoy

- 369
- 2
- 11

- 9,274
- 5
- 30
- 47
-
Actually, what I mean is: Eclipse has a "save to disk" icon which says "save highlighted items" or some such; I'm just wondering how to highlight all of the items. I don't want to "shell out" if possible. It's more convenient to stay in the Eclipse IDE. – B. Clay Shannon-B. Crow Raven Nov 26 '11 at 07:37
-
1how to sort by application? – NickUnuchek Jul 16 '14 at 10:49
-
2Or `adb logcat -f logcat.txt`, as shown in [documentation](https://developer.android.com/studio/command-line/logcat.html). – Franklin Yu Oct 06 '17 at 18:06
-
2@FranklinYu Unfortunately, the -f option to logcat appears to be only able to create files on the file system of the android device and not on the development host. [reference](https://stackoverflow.com/a/23521349/1299792) – Marklar Apr 05 '18 at 00:47
-
10This will keep `logcat` open. If you want to just dump the contents up until that point and exit the command, you need to add the `-d` (i.e. "dump") option: `adb logcat -d > logcat.txt`. – Joshua Pinter Apr 02 '20 at 15:51
-
@JoshuaPinter is it possible to get the content of the last few days? It seems that `adb logcat -d > logcat.txt.` gives me only last 30 minutes or so – Keselme Jun 22 '22 at 11:58
In addition to answer by Dinesh Prajapati, Use
adb -d logcat <your package name>:<log level>
where -d is for device and you may also choose -e instead for emulator log and log level is a/d/i/v/e/w etc.
Now your command goes like:
adb -d logcat com.example.example:V > logfileName_WithPath.txt
-
This is what I'm searching for.Thank you! Is there more detail format? – linjiejun Sep 22 '20 at 03:40
-
Two ways to do what you want:
- Right-click in the logcat messages window, choose select all. Then your save will be all logcat messages in that window (including the ones scrolled out of view).
- When focus is in logcat messages window, type control-A, this will select all messages. Then save etc. etc.

- 13,086
- 10
- 64
- 108

- 2,738
- 1
- 19
- 32
To save LogCat log to file programmatically on your device use for example this code:
String filePath = Environment.getExternalStorageDirectory() + "/logcat.txt";
Runtime.getRuntime().exec(new String[]{"logcat", "-f", filepath, "MyAppTAG:V", "*:S"});
"MyAppTAG:V"
sets the priority level for the MyAppTAG
to Verbose (lowest priority)
"*:S"
sets the priority level for all tags to "silent"
More information about logcat here.
-
How to add time to be shown in logs with the filter by package name. I try something like this Runtime.getRuntime() .exec(new String[] { "logcat", "-f", "time", filePath }); – kamal_tech_view Mar 12 '14 at 10:23
-
1@kamal_tech_view this should work. That is my piece of code that works: Runtime.getRuntime().exec(new String[]{"logcat", "-v", "time", "-f", filePath}); – yuralife Mar 12 '14 at 11:34
-
thanks @yuralife, I was also done it, how can we filter by package name – kamal_tech_view Mar 12 '14 at 12:43
-
we need to run this command only once or multiple times, as on Android 11 Chromebook it is working fine when run once and on Android 10 Tablet it stops writing to a file when run once, when i run it again then it writes to the same file – NarenderNishad May 09 '22 at 06:40
Use logcat tool with -d
or -f
switch and exec() method.
Saving to a file on the host computer:
exec( "adb logcat -d > logcat.log" ) // logcat is written to logcat.log file on the host.
If you are just saving to a file on the device itself, you can use:
exec( "adb logcat -f logcat.log" ) // logcat is written to logcat.log file on the device.

- 45,245
- 23
- 243
- 245

- 93,659
- 19
- 148
- 186
Open command prompt and locate your adb.exe(it will be in your android-sdk/platform-tools)
adb logcat -d > <path-where-you-want-to-save-file>/filename.txt
If you omit path, it will save logcat in current working directory
The -d option indicates that you are dumping the current contents and then exiting. Prefer notepad++ to open this file so that you can get everything in a proper readable format.

- 5,763
- 3
- 28
- 37

- 1,867
- 2
- 23
- 38
An additional tip if you want only the log shown in the past half hour with timestamps, or within another set time. Adjust date format to match your system. This one works on Ubuntu 16.04LTS:
adb shell logcat -d -v time -t "$(date '+%m-%d %H:%M:%S.%3N' -d '30 minutes ago')" > log_name.log

- 153
- 2
- 8
String filePath = folder.getAbsolutePath()+ "/logcat.txt";
Runtime.getRuntime().exec(new String[]{"logcat", "-f", filePath, "MyAppTAG:V", "*:E"});

- 18,405
- 4
- 60
- 77

- 311
- 1
- 5
- 11
Additional tip for the programmatic approach:
String filePath = Environment.getExternalStorageDirectory() + "/logcat.txt";
Runtime.getRuntime().exec(new String[]{"logcat", "-f", filepath, "MyAppTAG:V", "*:S"});
This opens a continuous output stream between logcat and the file provided. This can result in a deadlock if you then waitFor the Process returned by exec, or an exception if the provided file is prematurely disposed.
I found that including the "-d" flag simply dumps logcat and closes the connection, which prevents the above behavior.

- 44
- 2
If you are in the console window for the device and if you use Teraterm, then from the Menu do a File | Log and it will automatically save to file.

- 3,396
- 6
- 52
- 107
If you're on Android Studio (I'm using Electric Eel | 2022.1.1) on a Mac, you can left-click in the Logcat window (or the Run window), then press Command-a to select all the text. Then you can paste it into your favorite text editor and save it.

- 1,356
- 1
- 8
- 12