title: How to specify file location for logback on Android
body: <p>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.</p>
  
  <p>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?</p>
  
  <pre><code>&lt;configuration debug="true"&gt;
      &lt;!-- Create a file appender for a log in the application's data directory --&gt;
      &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;file&gt;/storage/emulated/0/data/data/mypackage/files/log/debug.log&lt;/file&gt;
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"&gt;
              &lt;fileNamePattern&gt;debug.%i.log.zip&lt;/fileNamePattern&gt;
              &lt;minIndex&gt;1&lt;/minIndex&gt;
              &lt;maxIndex&gt;3&lt;/maxIndex&gt;
          &lt;/rollingPolicy&gt;
          &lt;triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"&gt;
              &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
          &lt;/triggeringPolicy&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;!-- Write INFO (and higher-level) messages to the log file --&gt;
      &lt;root level="INFO"&gt;
          &lt;appender-ref ref="FILE" /&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>