How to read the STORED logs from an attached device in Android Studio

I need to read the logs that are stored in a device that I have attached by USB. It's set up for debugging. I run the Device File Explorer and it shows all the files. But where are the log files hidden?

1 answer

  • answered 2018-07-11 02:49 Sagar

    AFAIK, the Android System does not keep a Log File, rather it has a temp buffer which contains logs.

    Approach 1:Write logs to file in internal storage through code

    You need to write logs to the device by yourself. There are libraries like logback-android which can assist in doing so. You just need to create proper configuration in order to write logs on the device storage.

    Approach 2: Write logs to file using adb command

    Since you are connected through USB you can do

    adb logcat -d > logcat.txt

    The above command stores file on PC and not on device. Its in the same directory pointed by the command prompt

    Approach 3: Use Android Studio

    Connect your device to PC and run Android studio. At the bottom, you have logcat tab. You can view the logs and also save them to a text file.