Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot write to /storage/emulated/0/MyAppDirectory #236

Closed
tony19 opened this issue Feb 14, 2022 · 1 comment
Closed

Cannot write to /storage/emulated/0/MyAppDirectory #236

tony19 opened this issue Feb 14, 2022 · 1 comment

Comments

@tony19
Copy link
Owner

tony19 commented Feb 14, 2022

Originally posted by @kunalvaibhav in #228 (comment):

I am also getting similar issue but not logging in document directory. I wanted to have separate directory for my app. so trying to save log in "/storage/emulated/0/MyAppDirectory/logs" path. and it never created any log or directory for log.

compileSdk & targetSdk are 31.
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'com.github.tony19:logback-android:2.0.0'
and config logback.xml is taken from https://github.com/tony19/logback-android/wiki

app has below permission as well:
android.permission.WRITE_EXTERNAL_STORAGE"
android.permission.MANAGE_EXTERNAL_STORAGE"

Error in logcat:
I/System.out: 00:30:12,036 |-ERROR in ch.qos.logback.core.FileAppender[DebugLog] - Failed to create parent directories for [/storage/emulated/0/MyAppDirectory/logs/debug.log]

@tony19
Copy link
Owner Author

tony19 commented Feb 14, 2022

@kunalvaibhav Your issue is a bit differeent than #228.

In your case, you configured the log file location to be /storage/emulated/0/MyAppDirectory/logs/debug.log, which is in the root of /storage/emulated/0/. Android 11 doesn't allow writing to that location even with the permissions you requested.

You should change the location to be a subdiretory of Download (note it's singular) or Documents, as in:

/storage/emulated/0/Download/MyAppDirectory/logs/debug.log

# or
/storage/emulated/0/Documents/MyAppDirectory/logs/debug.log

@tony19 tony19 closed this as completed Feb 14, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant