I'm writing logs using slf4android (https://github.com/bright/slf4android) but it is not obvious how to read them (ideally I would just like to download them to my computer). The internal storage of the app is not accessible to other apps. Can I configure the slf4android to log to a shared directory? I've tried this but I get NOENT:
FileLogHandlerConfiguration fileHandler = LoggerConfiguration.fileLogHandler(this);
File lol = this.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS);
fileHandler.setFullFilePathPattern(fileHandler.toString() + "/my_log.%g.%u.log");
LoggerConfiguration.configuration().addHandlerToRootLogger(fileHandler);
Once you configured logging to a file by:
FileLogHandlerConfiguration fileHandler = LoggerConfiguration.fileLogHandler(this);
fileHandler.setFullFilePathPattern("/sdcard/your.package/my_log.log");
LoggerConfiguration.configuration().addHandlerToRootLogger(fileHandler);
There are two (both simple) ways to get a log file:
Using NotifyDeveloperHandler
(my favourite)
slf4android has a very nice feature (for some reason undocumented) which allows sending an email to a given address with logs and screenshot included in an attachment.
NotifyDeveloperHandler handler = LoggerConfiguration.configuration().notifyDeveloperHandler(this, "[email protected]");
handler.notifyWhenDeviceIsShaken();
LoggerConfiguration.configuration().addHandlerToRootLogger(handler);
it's really handy to use (literally) because you can trigger a send action by shaking your device.
Using adb
Run adb pull /sdcard/your.package/my_log.log ~/my_log.log
in terminal to copy log file from the device to home directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With