I have implemented a solution
try {
var process = Runtime.getRuntime().exec("logcat ${BuildConfig.APPLICATION_ID}:V brief output")
process = Runtime.getRuntime().exec("logcat -f " + "/storage/emulated/0/"+"Logging.txt")
} catch (e: Exception) {
e.printStackTrace()
}
This works for a few minutes and then stops on Android 10. Any idea what could be the reason that it stops writing log to the file?