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

Impossible to create log file #3

Closed
karfam opened this issue Mar 9, 2020 · 1 comment
Closed

Impossible to create log file #3

karfam opened this issue Mar 9, 2020 · 1 comment

Comments

@karfam
Copy link

karfam commented Mar 9, 2020

Having exception with the export to csv file

Kotlin 1.3.70
Lintoptions enabled

Init Log Function

        LoggerConfigurator.init(
            Logger.Level.WARN,  /* Minimum level to log */
            123,  /* Application ID */
            "AndroidLogApp",  /* Application name */
            BuildConfig.VERSION_NAME,  /* Application version */
            "123456789",  /* Device ID */
            "AndroidLogApp.log"
        ) /* File name prefix */
        LoggerConfigurator.addAppender(LogcatAppender(LogcatLayout()))
        LoggerConfigurator.addAppender(FileAppender(applicationContext, CsvLayout()))
    }

And here is the logcat

E/AndroidLogApp: java.io.FileNotFoundException: /storage/emulated/0/logs/AndroidLogApp/AndroidLogApp.log20200309: open failed: ENOENT (No such file or directory)
 at libcore.io.IoBridge.open(IoBridge.java:496)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
        at java.io.FileWriter.<init>(FileWriter.java:107)
        at com.ech0s7r.android.log.service.WriterService.f(SourceFile:150)
        at com.ech0s7r.android.log.service.WriterService.a(SourceFile:45)
        at com.ech0s7r.android.log.service.WriterService$b.run(SourceFile:67)
     Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
        at libcore.io.Linux.open(Native Method)
        at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
        at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
        at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
        at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7419)
        at libcore.io.IoBridge.open(IoBridge.java:482)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:235) 
        at java.io.FileWriter.<init>(FileWriter.java:107) 
        at com.ech0s7r.android.log.service.WriterService.f(SourceFile:150) 
        at com.ech0s7r.android.log.service.WriterService.a(SourceFile:45) 
        at com.ech0s7r.android.log.service.WriterService$b.run(SourceFile:67) 
@karfam
Copy link
Author

karfam commented Mar 9, 2020

https://developer.android.com/reference/android/os/Environment

getExternalStorageDirectory()
This method was deprecated in API level 29. To improve user privacy, direct access to shared/external storage devices is deprecated. When an app targets Build.VERSION_CODES.Q, the path returned from this method is no longer directly accessible to apps. Apps can continue to access content stored on shared/external storage by migrating to alternatives such as Context#getExternalFilesDir(String), MediaStore, or Intent#ACTION_OPEN_DOCUMENT.

class LoggerConfigurator line 31
APP_DIR_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/logs/" + APP_NAME;

Repository owner deleted a comment from uc-Pri Mar 18, 2024
@karfam karfam closed this as completed Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant