[logback-user] logback android - robolectric tests console output is missing native android logging statements

athanasios kaliakoudas sakis.kaliakoudas at hotmail.com
Fri Dec 5 15:25:03 CET 2014


Logging statements found in the android source code that are not slf4j, but in the form of

Log.e(TAG, "details"); 
do not appear in console.

Some of my robolectric tests were failing and as I was going through the code I noticed that in the android class "android.database.sqlite.SQLiteDatabase" method there is a method "insert" that looks like this:

public long insert(String table, String nullColumnHack, ContentValues values) {
    try {
        return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE);
    } catch (SQLException e) {
        Log.e(TAG, "Error inserting " + values, e);
        return -1;
    }
}
When my test run this method returned -1 but after looking at the output in Intellijs console I noticed that the log statement explaining the error was missing. Is there a way for this statement that is not slf4j to be displayed in the console? I assume that if I was running the application and the same error occurred it would appear in the logcat window.

my logback.xml for tests looks like this

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <property name="appender.encoder.pattern" value="%d | %-10r | %5p | %-30t | %-100logger{100} | %-50M | %-5L | %m %n"/>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${appender.encoder.pattern}</pattern>
        </encoder>
    </appender>

    <logger name="com.myapp">
        <level value="TRACE"/>
    </logger>

    <root>
        <level value="INFO"/>
        <appender-ref ref="CONSOLE"/>
    </root>

</configuration>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20141205/86cd4ee4/attachment.html>


More information about the Logback-user mailing list