Trying to redirect log messages using logback-android so that messages can be saved to a file. However, it is not saved in the file.
This is my logback.xml file configuration, which is stored in src / main / assets in my android studio
<configuration debug="true"> <appender name="FILE" class="ch.qos.logback.classic.android.FileAppender"> <file>/data/com.test.equa/files/log/foo.log</file> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="FILE" /> </root> </configuration>
This is a piece of code in which I start logging.
@Override public void onCreate() { super.onCreate(); loadData(); Logger log = LoggerFactory.getLogger(MyActivity.class); log.error("Application Data setup in progress"); }
Problem: I continue to see messages in logcat, but I expect that they will be saved in my Android sd card memory.
Added custom permission in the manifest for recording logs on the SD card
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I am missing some thing in this configuration since I do not see any errors or messages in my logcat for any configuration errors. Can someone help me here.
source share