Calling Log.e(TAG, "some message", e)
where e
is an UnknownHostException
, does not print the stack trace on the logcat.
Asked
Active
Viewed 893 times
12

Randy Sugianto 'Yuku'
- 71,383
- 57
- 178
- 228
2 Answers
17
Since May 20, 2011, there is a change in the Log
class, such that UnknownHostException
exceptions are not printed.
This is to reduce the amount of log spew that apps do in the non-error condition of the network being unavailable. https://github.com/android/platform_frameworks_base/commit/dba50c7ed24e05ff349a94b8c4a6d9bb9050973b

Randy Sugianto 'Yuku'
- 71,383
- 57
- 178
- 228
-
1@SatelliteSD I tried to but SO told me I need to wait 2 days. I put it here since I didn't find this problem mentioned elsewhere. Even the Android docs didn't mention about this =( – Randy Sugianto 'Yuku' Mar 06 '15 at 11:05
-
This seems completely inappropriate! If I do: `Log.e(LOG_TAG, "Ouch!", throwable)` I expect the exception message and traceback to *always* be logged. At the very least I'd expect this to be elided down to "Unknown host: foo.bar", not simply have the entire message and stack go away!!! – user6519354 Feb 03 '20 at 18:55
-3
The e
you are including is useless, remove it and it would be visible in logcat
.
Log.e(TAG, "some message");

Apurva
- 7,871
- 7
- 40
- 59
-
No. It works, there was no error, but the stack trace is not printed on the logcat. – Randy Sugianto 'Yuku' Mar 06 '15 at 10:55
-
@yuku oh! It was my mistake, and up to I know, only two parameters are allowed in log.e – Apurva Mar 06 '15 at 10:58
-
1No, you can most definitely log a stacktrace http://developer.android.com/reference/android/util/Log.html#e(java.lang.String, java.lang.String, java.lang.Throwable) – ci_ Mar 06 '15 at 11:00