How to get log file using SLF4j in android

Viewed 6228

I've implemented code for creating log file using slf4j in android but couldn't succeeded.

First I've added gradle dependency as per below:-

compile 'org.slf4j:slf4j-android:1.6.1-RC1'
compile 'com.github.tony19:logback-android-core:1.0.7-1'

Then as per the guidelines i created a configuration file in assets folder named as logback.xml as per below :-

<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>/sdcard/testFile.log</file>
    <append>true</append>
    <encoder>
        <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
</appender>

<root level="DEBUG">
    <appender-ref ref="FILE" />
</root>

Finally I add a log in my application like below:-

Logger logger = LoggerFactory.getLogger(HomeActivity.class);
logger.debug("Testing slf4j", "Hello world");

Now I ran this program and expecting the a log file there in SDcard but unfortunately no such file is seen. Please let me know if I am missing anything. If anybody have made it in android application, please help me out.

Thanks.

1 Answers
Related