I am new to android development.I want to write logs to one file in SD Card.How can i do this using Log4j.What all are the steps to Implement Log4j.I read many atricles.But none of them describing how to configure and implement it.Can anyone please explain how to do this in android in simple words.
Share
You should look at
logback(the next generation of log4j). Use theFileAppenderorRollingFileAppender.Instructions:
Add
slf4j-api-1.6.6.jarandlogback-android-1.0.6-2.jarto your classpath.Create the file
assets/logback.xmlin your project (or use theAndroidManifest.xml…see example), containing the following configuration:Note: Since the specified path is on SD, make sure to use
WRITE_EXTERNAL_STORAGEpermission. You can instead specify a different path where you already have write permissions.Your Java code, which contains the SLF4J logging calls, now logs all events at or above the
DEBUGlevel to the/sdcard/testFile.log.Example Java: