How does Log.wtf() differ from Log.e()?

Solution 1:

There is a difference in severity;

Log.e() will simply log an error to the log with priority ERROR.

Log.wtf() will log an error with priority level ASSERT, and may (depending on the system configuration) send an error report and terminate the program immediately.

Solution 2:

COMMON MISTAKE

Official docs say:

Log.e() logs with priority ERROR. However, Log.wtf() logs with priority ASSERT.

ASSERT has priority constant = 7
ERROR has priority constant = 6

So Log.wtf() has higher priority with respect to Log.e()

However source code conflicts with above information.

static int wtf(int logId, String tag, String msg, Throwable tr,boolean localStack, boolean system) {
        
    TerribleFailure what = new TerribleFailure(msg, tr);
    // Only mark this as ERROR, do not use ASSERT since that should be
    // reserved for cases where the system is guaranteed to abort.
    // The onTerribleFailure call does not always cause a crash.
    int bytes = printlns(logId, ERROR, tag, msg, localStack ? what : tr);
    ...
}

It looks like there is a mistake in Official docs. Because both Log.wtf() and Log.e() logs with priority ERROR.

REAL DIFFERENCE

Source Code for Log.e():

public static int e(@Nullable String tag, @Nullable String msg,@Nullable Throwable tr) {
    return printlns(LOG_ID_MAIN, ERROR, tag, msg, tr);
}

The difference is that Log.wtf() might call onTerribleFailure() call back.

onTerribleFailure() may or may not cause the process to terminate (depends on system settings).

TL;DR

Log.wtf() might call onTerribleFailure() and can cause termination of your application.

Solution 3:

Log.e() is the simply log an error to the log with priority as ERROR.

Log.wtf() (What a terrible failure) is more severe than error log. The error which never ever ever, ever happened. It may force the device to hold for writing the logs before terminate the program.