Treessence
Treessence copied to clipboard
Crash when setting up File Logger Tree
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
Any help would be appreciated. Thank you!
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.
There is no sample usage of how we need to pass the directory path. Giving rise to confusion.
@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)