Android Best Logger For Logging Into File
Solution 1:
slf4j-android only supports logging to logcat and thus omits several classes from the regular SLF4J jar. If you want to use logback to log to a file, you need the API jar (not slf4j-android) and logback-android. You're looking for the FileAppender or RollingFileAppender.
Instructions:
Add
slf4j-api-<version>.jarandlogback-android-<version>.jarto your classpath.Create the file
assets/logback.xmlin your project (or use theAndroidManifest.xml...see example), containing the following configuration:
<configuration><appendername="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><rootlevel="DEBUG"><appender-refref="FILE" /></root></configuration>Note: Since the specified path is on SD, make sure to use WRITE_EXTERNAL_STORAGE permission. 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 DEBUG level to the /sdcard/testFile.log.
Solution 2:
Make a folder named "libs" and put the jar inside that folder.
Post a Comment for "Android Best Logger For Logging Into File"