I need to be able to write logs to disk so that for debugging purposes it can be sent to me by the user. If I use the Log class in android, it has the ability to write only logcat, and logcat is not so useful as the corresponding logs may disappear after a while. Therefore, it is important for me that the logs are written to disk and can be restored later at any time. Therefore, I require Logcat as functionality (a ring buffer of a limited size), but persisted on disk so that it is preserved during application crashes and device restarts.
Is there any existing class in android that can help me
- write logs to disk,
- Is the thread safe
- and implements some kind of ring buffer on the disk (so the log file cannot become a more predetermined size and always have the latest logs)
It must also be executed with sizes equal to the default ring buffer size of the existing Logcat implementation (from 64 KB to 1 MB on higher end devices).
I really do not want to reinvent the wheel, and I am happy to use a third-party library, if necessary, please let us know.
Otherwise, how can this be implemented with the existing Android API and class library?
source
share