diff --git a/app/build.gradle b/app/build.gradle
index bf3f51a7..a1505890 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -23,5 +23,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
- compile 'com.noveogroup.android:android-logger:1.3.5'
+// compile 'com.noveogroup.android:android-logger:1.3.5'
+ compile 'com.github.tony19:logback-android-classic:1.1.1-3'
+ compile 'org.slf4j:slf4j-api:1.7.7'
}
diff --git a/app/src/main/assets/logback.xml b/app/src/main/assets/logback.xml
new file mode 100644
index 00000000..4cab9d3c
--- /dev/null
+++ b/app/src/main/assets/logback.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+ ${GB_LOGFILES_DIR}/gadgetbridge.log
+ true
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{25} - %msg%n
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java
index cee47fee..263f2fa9 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java
@@ -3,6 +3,17 @@ package nodomain.freeyourgadget.gadgetbridge;
import android.app.Application;
import android.content.Context;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.util.FileUtil;
+import ch.qos.logback.core.util.StatusPrinter;
+
public class GBApplication extends Application {
private static GBApplication context;
@@ -10,6 +21,29 @@ public class GBApplication extends Application {
context = this;
}
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ setupLogFileDir();
+// For debugging problems with the logback configuration
+// LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+// print logback's internal status
+// StatusPrinter.print(lc);
+// String dataDir = lc.getProperty(CoreConstants.DATA_DIR_KEY);
+// String filename = FileUtil.prefixRelativePath(dataDir, "gadgetbridge.log");
+// Logger logger = LoggerFactory.getLogger(GBApplication.class);
+ }
+
+ private void setupLogFileDir() {
+ File dir = getExternalFilesDir(null);
+ if (dir != null && !dir.exists()) {
+ dir.mkdirs();
+ }
+ // used by assets/logback.xml since the location cannot be statically determined
+ System.setProperty("GB_LOGFILES_DIR", dir.getAbsolutePath());
+ }
+
public static Context getContext() {
return context;
}
diff --git a/app/src/main/resources/logback.xml b/app/src/main/resources/logback.xml
new file mode 100644
index 00000000..2cec774c
--- /dev/null
+++ b/app/src/main/resources/logback.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+ gadgetbridge.log
+
+
+
+
+ %date [%thread] %-5level %logger{25} - %msg%n
+
+
+
+
+
+
+
\ No newline at end of file