Log Directory Not Recognized After App Reinstallation
When setting a custom logDirectory, such as /storage/emulated/0/Download/logs/, the library successfully writes logs to the specified directory. However, if the app is uninstalled and then reinstalled, the library fails to recognize the previously set logDirectory. Calling getLogFilePaths() after reinstallation returns an empty array, even though the log files still exist in the directory.
Steps to Reproduce: 1. Configure react-native-file-logger with a custom logDirectory, for example: /storage/emulated/0/Download/logs/. 2. Write logs and verify that log files are created in the specified directory. 3. Uninstall the app. 4. Reinstall the app. 5. the app fails to write logs... calling getLogFilePaths return an empty array. Edit: Tested only on android
I'm having the same issue
After some investigation, I found out that this is related to file permissions. After uninstalling and reinstalling the app, your app gets a different app ID so the owner of the previously created files is the previous instance of the app and as a result of that you cannot change anything to the existing files. My solution was to install react-native-device-info and inside the logs folder create new folders with the instance id of the installation, in that way having different folders with logs, corresponding to each installation of the app. Hope that helps anyone
I am facing the same issue. This only happens after a fresh app installation. If I reopen the app, the issue no longer occurs.
I mitigated this issue by calling the FileLogger.configure({...}); twice after a delay of 1s.
@alois-beto This has become a MAJOR issue for us, actually. Apparently, the above workaround does not always work, and logs recorded immediately after the app starts are sometimes not written to the log file.