I want to write logback output to a log file which can then be sent back to me by the user. My logback.xml is below. My problem is that my logging will only work if the location that I specify is "/storage/emulated/0"...(which is device-specific). If I simply specify "/data/data/mypackage/files/log/debug.log" then nothing gets written.
What is the best way of specifying the path for my file in a way which will be compatible with all Android 4.x devices?
<configuration debug="true">
<!-- Create a file appender for a log in the application's data directory -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/storage/emulated/0/data/data/mypackage/files/log/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>debug.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- Write INFO (and higher-level) messages to the log file -->
<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>