Treessence icon indicating copy to clipboard operation
Treessence copied to clipboard

Crash when setting up File Logger Tree

Open geldf opened this issue 1 year ago • 2 comments

Hello, this library has been successfully integrated into our app.

However, according to Firebase Crashlytics, a few users encountered the issue below. We are unable to duplicate the same problem though. Here is the stack trace:

Caused by java.io.IOException: Couldn't get lock for /data/user/0/app_name/files/error_log/01_09_2023%g.txt at java.util.logging.FileHandler.openFiles(FileHandler.java:439) at java.util.logging.FileHandler.<init>(FileHandler.java:403) at .. at .. at .. at .. at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190) at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7184) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7134) at android.app.ActivityThread.access$1600(ActivityThread.java:274) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2102) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Devices are Oppo, Samsung, Vivo image

Any help would be appreciated. Thank you!

geldf avatar Sep 04 '23 07:09 geldf

Same issue seen on my Pixel 4:

15:55:09.939 W java.nio.file.NoSuchFileException: Download/Options.log.0.lck 15:55:09.939 W at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:183) 15:55:09.940 W at java.nio.channels.FileChannel.open(FileChannel.java:292) 15:55:09.940 W at java.nio.channels.FileChannel.open(FileChannel.java:345) 15:55:09.940 W at java.util.logging.FileHandler.openFiles(FileHandler.java:460) 15:55:09.940 W at java.util.logging.FileHandler.(FileHandler.java:403) 15:55:09.940 W at fr.bipi.treessence.file.FileLoggerTree$Builder.build(FileLoggerTree.kt:249) ... 15:55:09.940 W at android.os.MessageQueue.nativePollOnce(Native Method) 15:55:09.940 W at android.os.MessageQueue.next(MessageQueue.java:335) 15:55:09.941 W at android.os.Looper.loopOnce(Looper.java:161) 15:55:09.941 W at android.os.Looper.loop(Looper.java:288) 15:55:09.941 W at android.os.HandlerThread.run(HandlerThread.java:67)

There is no sample usage of how we need to pass the directory path. Giving rise to confusion.

Wolf00Bomber avatar Oct 31 '23 10:10 Wolf00Bomber

@geldf Seems I was able to bypass this exception when I created a log file in External Downloads Folder: (Note: I have not tried the data folder yet!)

val t: Timber.Tree = FileLoggerTree.Builder()
            .withFileName("${DateUtils.getSimpleDate()}.log")
            .withDirName(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath)
            .withSizeLimit(10 * SIZE_LIMIT) // ~ 10 MB
            .withFileLimit(1)
            .withMinPriority(Log.VERBOSE)
            .appendToFile(true)
            .build()
Timber.plant(t)

Wolf00Bomber avatar Oct 31 '23 11:10 Wolf00Bomber