j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 367 forks source link

Android app using LocalLog instead of Logcat #59

Closed Macarse closed 2 years ago

Macarse commented 8 years ago

I just figured out that the android app I work for was using LocalLog instead of Logcat. (https://nimbledroid.com/play/com.groupon#logger.LocalLog%20static%20initializer)

After debugging a bit I noticed that com.j256.ormlite.android.AndroidLog was getting removed from the APK by Proguard. To fix this I modified our proguard.cfg with:

-keep class com.j256.ormlite.android.AndroidLog { *; }

I also added:

System.setProperty(LoggerFactory.LOG_TYPE_SYSTEM_PROPERTY, "ANDROID");

To my Application code. When AndroidLog is not available, you will see a log statement like this:

System.out(13038): 2016-02-13 15:51:08,360 [WARNING] StatementExecutor Unable to call constructor with single String argument for class com.j256.ormlite.android.AndroidLog, so had to use local log: com.j256.ormlite.android.AndroidLog

@j256 it might be interesting mentioning this in the Logging section of the docs.

dazza5000 commented 7 years ago

Would it be possible to add functionality to disable logging by ormlite-android (for security reasons)

j256 commented 2 years ago

In version 5.7 we removed the annoying log statements about missing classes. You also can force the logging backend with LoggerFactory.setLogBackendFactory(LogBackendType.ANDROID);.

To disable all logs @dazza5000, you can use LoggerFactory.setLogBackendFactory(LogBackendType.NULL);.

I'll add both of these to the docs. Thanks @Macarse