logback-android
logback-android copied to clipboard
EXT_DIR value depends on Android version
Related to commit #208:
getExternalStorageDirectory() returns root card path, while getExternalFilesDirectoryPath() returns app data specific path. So property EXT_DIR in logback.xml would get different values depend on Android version.
I think it would be something like this:
public String getExternalStorageDirectoryPath() {
if (Build.VERSION.SDK_INT >= 29) {
return getExternalFilesDirectoryPath();
} else {
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + getPackageName() + "/files";
}
Your suggestion is to make $EXT_DIR
/getExternalStorageDirectoryPath()
always return the app-specific external files dir, but I think that defeats the purpose of the function, which is to return the root of the external storage path. I missed that in my original review of #208.
The more correct fix to me is to make $EXT_DIR
/getExternalStorageDirectoryPath()
always return the root of the external storage like it did before #208. In either case, this would be as a breaking change, as users might be relying on the current behavior in their configs.
I think I'll address this by:
- documenting the current behavior with a warning
- deprecating
$EXT_DIR
, emitting a runtime deprecation warning in the logs - adding a new special variable to replace
$EXT_DIR
(e.g.,$EXTERNAL_STORAGE_DIR
) - adding a new special variable specifically for external files dir (e.g.,
$EXTERNAL_FILES_DIR
) (related #181).
🤔
Any update on this? We are having to use a custom PropertyDefiner
to work around this issue, whereas in earlier versions we were directly using EXT_DIR
in the config.