135

I’m running some lengthy calculations and something goes wrong quite late. I tried using breakpoints, but with no success so far. So I put into the loop a Log.d to monitor...

But quite soon, Logcat crashes with:

02-08 16:35:42.820 2936-3402/com.nohkumado.geneticsolving.full D/BaseC: 
    norm:BC sq:49.0 dis:0.0 con:50.0/BC sq:56.0 dis:4.0 con:94.0=1.4069148936170213

    read: unexpected EOF!

    --------- beginning of crash

and I need to restart the studio to get Logcat running again.

I looked if I could find some setting for the buffer size for Logcat, but so far I’ve found nothing. What can be done?

0xCursor
  • 2,242
  • 4
  • 15
  • 33
Noh Kumado
  • 1,551
  • 2
  • 9
  • 15
  • 1
    The asker is conflating two unrelated things. The message "beginning of crash" means an Android app crashed, not logcat. The "read: unexpected EOF!" does actually come from the logcat process and it indicates that the logcat process lost its connection to the logd process. – satur9nine Nov 25 '19 at 21:56
  • Well, the app didn't crash, it was only not converging.... but i couldn't see it because of the buffer limitation of the logcat..... – Noh Kumado Nov 25 '19 at 22:40

16 Answers16

217

Fuller answer

The accepted answer didn't work for me. Rather than turning the logger buffer off, I increased it to the max size.

  1. Enable developer options in your emulator or device (not Android Studio) if it hasn't been enabled already: In your emulator or device go to Settings > System > About (emulated device) and click on Build number 7 times.
  2. Go to Settings > System > Developer options > Logger buffer sizes and choose a higher value.

enter image description here

  1. I also had to restart the emulator.

So the original problem apparently happens because the devices log buffer gets filled up for lengthy logging. Increasing the buffer size allows you to log more in a single logging session.

Community
  • 1
  • 1
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • 1
    Using this I can avoid the problem in a normal work day. There is an exception for me : using a Samsung phone in an environment with lots of Bluetooth devices. Samsung decided to log every Bluetooth scan in system level and apparently 16M is not be enough for this. It will still happen like 4 or 5 times a day when I have over 30 Bluetooth devices around me. – reTs Jul 25 '18 at 10:53
  • The logd buffer is a ring buffer, changing it's size should have no measurable impact on whether the connection between logcat and logd is lost. All it does is change how much logging history sits around in memory. It's highly unlikely this fixes the problem. – satur9nine Nov 25 '19 at 21:59
  • 1
    @satur9nine, I can't say whether it fixes the problem at the underlying level, but it fixed my problem in that it prevented the crash and allowed more log messages to be shown. – Suragch Nov 26 '19 at 02:20
  • After transferring a TWRP backup from one Moto G5 Plus to another, my logcat buffer consisted of some events from months ago, some events from today, followed by `read: unexpected EOF!`. Increasing to 16M fixed the problem and made the months-old events disappear. – nyanpasu64 Feb 18 '20 at 10:44
135

Try setting Logger buffer sizes to off under Settings->Developer options, on your device/emulator. This might be happening because Logger buffer is configured to display limited KB of logs only at a particular time. Next set of logs would only be displayed once previous buffer is cleared.

ymerdrengene
  • 1,421
  • 2
  • 17
  • 20
Rishabh
  • 1,827
  • 1
  • 12
  • 9
37

In Developer options you can set Logger buffer size to maximum 16M.
(Setting > System > Developer options > Logger buffer sizes)

If you need more you can set it using adb. For example you can set it to 100M:

adb logcat -G 100M
Lukk17s
  • 986
  • 10
  • 11
13

This log you posted is stating the app crashing (although not in the usual way with a stacktrace but it's crashing), not the logcat. Do you have the app selected and filter set to "Show selected application" in the logcat? If so just set the filter to "No Filter" and you'll see all the logs of your app.

Also in case you need to restart the logcat for any reason, rather than restarting Android Studio you could run the following commands which will restart adb and eventually restart your logcat as well:

adb kill-server
adb start-server
ahasbini
  • 6,761
  • 2
  • 29
  • 45
  • that is strange, because the app seems to continue working? i am usure about the computation itself (hence my wish to debug it) but the rest works, clicking on buttons etc continues to yield the expected behaviour? the adb trick restored the logcat, unfortunalely is skips then to the actual time point... – Noh Kumado Feb 08 '18 at 20:04
  • I thought what u meant by lengthy calculation and then something goes wrong meaning the app is probably becoming laggy or not responding and then crashing. Is the app composed of multiple activities? And when the error happen is it like returning back to a previous activity? No filter doesn't show all the logs right? – ahasbini Feb 08 '18 at 21:05
  • No the app runs smoothly its the results that at some point deviate from the expected, yes several activities and the worker threads are done with async tasks, and no after that crash msg, logcat remains bland for everything.... – Noh Kumado Feb 09 '18 at 01:00
7

use the following command:

adb logcat -G 20M
Elletlar
  • 3,136
  • 7
  • 32
  • 38
6

The recommendations did not work for me. I finally changed this preference setting:

Menu "Run", Menu Entry "Edit Configurations", then on the left side "Android App/app" and on the right side the tab "Miscellaneous", and finally activate "Logcat: Clear log before launch".

Of course this has side effects, but at least I can see the log output again.

Mike S.
  • 1,995
  • 13
  • 25
5
  1. remove all log.d and restart android studio and Just go to File -> Invalidate Caches / Restart.
  2. your device Settings->Developer options
  3. Change Log Buffer size
Lucky Agarwal
  • 51
  • 2
  • 1
3

If you are running from a real phone - disconnect & connect the phone from the usb worked for me (the buffer gets empty- like @Suragch suggested).

ALUFTW
  • 1,914
  • 13
  • 24
3

Changing the buffer size did not work for me. What did was changing my USB connection to a USB 3.0 port.

Prof
  • 657
  • 1
  • 14
  • 24
3

Restart your device! I have no idea why it works for me after restarting my mobile phone.

Ender
  • 835
  • 1
  • 12
  • 23
1

adb logcat -G 1m

Enter this on Terminal, it worked for me

Sabin Acharya
  • 493
  • 4
  • 9
1

Unfortunately this seems to be still an issue, i could not find a satisfying solution beside of installing a plugin(File -> Setting -> Plugins -> Marketplace) called "Log Viewer". Works better than the built-in logcat viewer of Android Studio.

kaya
  • 1,626
  • 1
  • 21
  • 27
1

just click on delete button and clean the past logs of your application

Just click on delete button and clean the past logs of your Application

Hope you get it.Thanks

0

I had the same problem as a result of reading a texting file in a while loop. I had two log.d statement in the while loop and the file size was ~220 MB. I removed the log.d statement in the while loop because it was making so many outputs in logcat. I increased the logcat size to the maximum possible. That worked for me although the processing time was long before I got the desired result.

Othello
  • 55
  • 11
0

Clear logcat

Others answers like increasing logcat memory will work. But after reaching certain threshold like 16mb, then same eof! file error would occur. So you can clear logcat in case. This issue won't occur after that. Even after clearing logcat also this issue occured means,you can increasing log buffer sizes.

moken
  • 3,227
  • 8
  • 13
  • 23
Kavin S
  • 1
  • 1
-1

Just go to File -> Invalidate Caches / Restart will let android studio do the job

Anonymous-E
  • 827
  • 11
  • 29
  • I don't think this will help with the problem itself, but the AS restart will restart logcat, apparently fixing the problem. – Aloha Apr 01 '20 at 08:00
  • @PNDA why not let android do validate your caches and restart it for u? I don't see where is the disadvantage – Anonymous-E Apr 01 '20 at 08:47