I am testing an app using two real devices and some virtual. When testing the app using a real Motorola Moto G 4G (1st gen.) or any virtual device the Lod.d() messages show as they are supposed to do. When testing in Sony Xperia E4 the Log.d() messages are not showing, while other log messages do. What's the problem?
-
Does this answer your question? [Logcat not showing debug level messages](https://stackoverflow.com/questions/13063164/logcat-not-showing-debug-level-messages) – SpaceBison Apr 01 '21 at 21:02
3 Answers
Testing on Sony Xperia E5 Android 6.0 I found out that Logcat
debug (Log.d) logs are ignored.
Accessing special factory settings through dialpad and *#*#7378423#*#*
code didn't have an option to enable debug logs (like Huawei devices have).
Also under Developer options
there weren't any options to enable debug logs.

- 6,449
- 8
- 37
- 69
Don't know if this will help you with Sony Xperia E4 but I'd recommend you to use custom Logger class. Here is an example:
public class Logger {
public static void debug(Class<?> cls, String message) {
if(BuildConfig.DEBUG)
Log.d(cls.getSimpleName(), "--------" + message);
}
public static void info(Class<?> cls, String message) {
Log.e(cls.getSimpleName(), "--------" + message);
}
public static void error(Class<?> cls, String message, Exception e) {
Log.e(cls.getSimpleName(), "--------" + message, e);
}
public static void warn(Class<?> cls, String message) {
Log.w(cls.getName(), "--------" + message);
}
public static void error(Class<?> cls, CharSequence message) {
Log.e(cls.getSimpleName(), "--------" + message);
}
}
You can turn on/off logs throu the BuildConfig when releasing your app. My Sony Xperia M2 shows logs correctly with this class. Try to use it in this way:
Logger.debug(SomeClass.class, "Log message");

- 218
- 7
- 17
-
check the toogle in **settings - developer options - Debugging - USB debugging**, maybe this will help. But I think you already have turned it on cause you can use ADB – Andrey Mohyla Apr 11 '16 at 18:18
I have the same device and had same problem. I tried all other ways adb-kill/restart, restart logger, android studio invalidate cache but didn't work at all.
In the end, I had to perform factory data reset.
now it's working.

- 4,522
- 4
- 32
- 48