I'm trying to set up my app so I can write logs using logback-android, and then send them to Google Docs using ACRA. I think this is possible but the one issue I have, is where to write the logs.
Both libraries need a hard-coded filename, so I can't use getStorageDirectory()
. So, my first question is, where do the logs get written if you don't specify a full path? Do I have to specify a full path and hardcode it to /data/data/com.example/...
?
Here's my configuration:
<!-- Logback configuration. -->
<logback>
<configuration>
<appender
name="FILE"
class="ch.qos.logback.core.FileAppender" >
<file>applog.log</file>
<encoder>
<pattern>[%method] %msg%n</pattern>
</encoder>
</appender>
<appender
name="LOGCAT"
class="ch.qos.logback.classic.android.LogcatAppender" >
<tagEncoder>
<pattern>%logger{0}</pattern>
</tagEncoder>
<encoder>
<pattern>[%method] %msg%n</pattern>
</encoder>
</appender>
<root level="debug" >
<appender-ref ref="FILE" />
<appender-ref ref="LOGCAT" />
</root>
</configuration>
</logback>
And for acra:
@ReportsCrashes(formKey = "dDB4dVRlTjVWa05T..........................",
applicationLogFile = "applog.log",
applicationLogFileLines = 150)
But this gives errors like the following, so clearly I do need an absolute path. What should I use?
java.io.FileNotFoundException: /applog.log: open failed: EROFS (Read-only file system)
Final, slightly unrelated question, I want to be able to print the object address, something like [%object :: %method] which would show [MyActivity@33c0d9d :: onCreate] or something similar. Is there any way to do that?