sentry-java: Sentry Android does not capture LogCat logs
Platform:
- Android -> If yes, which Device API (and compileSdkVersion/targetSdkVersion/Build tools) version?
- Java -> If yes, which Java (and sourceCompatibility/targetCompatibility) version?
- Kotlin -> If yes, which Kotlin (and jvmTarget) version?
- NDK -> If yes, which NDK/CMake version?
- React-Native -> If yes, which version?
- Timber -> If yes, which version?
- Log4j2 -> If yes, which version?
- Logback -> If yes, which version?
- Spring -> If yes, which version?
IDE:
- Android Studio -> If yes, which version?
- IntelliJ -> If yes, which version?
- Other -> If yes, which one?
Build system:
- Gradle -> If yes, which version?
- Buck -> If yes, which version?
- Bazel -> If yes, which version?
- Maven -> If yes, which version?
- Other -> If yes, which one?
Android Gradle Plugin:
- Yes -> If yes, which version?
- No
Sentry Android Gradle Plugin:
- Yes -> If yes, which version?
- No
Proguard/R8:
- Enabled
- Disabled
Platform installed with:
- JCenter
- Bintray
- Maven Central
- Manually
The version of the SDK: 3.x.x
I have the following issue:
The description goes here …
Steps to reproduce:
- run sample
Actual result: Sentry Android does not capture LogCat logs
Expected result:
when having things like Log.i(...), I hope sentry can automatically capture it.
thank you!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 32 (17 by maintainers)
We’ve shipped this. See https://docs.sentry.io/platforms/android/configuration/integrations/logcat/
Our logcat integration only includes creating breadcrumbs out of logs with a specified
minLevelwhich you can configure in yourbuild.gradle(which also includes logs by third-party libraries since our implementation is based on bytecode manipulation).If you still want to log the last n number of logs as an attachment you can still do that as you currently do by adding an
EventProcessorand injecting a logcat shell command.I suspect we can reuse this logcat parser from the Android framework itself https://cs.android.com/android/platform/superproject/+/master:development/tools/bugreport/src/com/android/bugreport/logcat/LogcatParser.java
We can execute
Runtime.getRuntime().exec("logcat -v time");and listen the buffer in a while loop. https://github.com/pedrovgs/Lynx/blob/master/lynx/src/main/java/com/github/pedrovgs/lynx/model/Logcat.javaMy requirement is:
I find a workaround:
Is there a way to manual install Logcat Integration? I don’t want to install with the Sentry Android Gradle Plugin. @buenaflor
https://developer.android.com/studio/preview/features#logcat
Not sure if the logcat output has changed or the IDE is parsing it, but worth checking it when working on this issue, worst case we have to parse 2 formats.
Use code below to upload logcat including native crash happened
It does, but not for all versions apparently. https://github.com/pedrovgs/Lynx/blob/7b1f25172f2bd3f4563076dcd58ec532aebfb9f1/sample/src/main/AndroidManifest.xml#L20-L21 Well, ideally this is done on a background thread, but I don’t have benchmarking data, it’d be an opt-in feature till we get proper feedback anyway.
it’d be possible ootb only via bytecode manipulation or executing
logcat params...and writing the output to a file or parsing the text, of course. I’m not sure if it’s a good idea though since it’s rather a good practice to remove every logcat call from production apps via Proguard/R8 to reduce the app’s size, there’s some cost in it, but obviously, a nice feature to have. I’m just questioning the usage oflogcatin production Apps here to identify issues.