On Android I'm using Timber with java.util.logging.Logger and FileHandler to write the logs on files. I have debugged the code and seems it write the log on file on the same caller's method thread. Do you know why ? In this way, it can be a problem to call the log methods on the ui thread.
Asked
Active
Viewed 127 times
1 Answers
0
Do you know why ? In this way, it can be a problem to call the log methods on the ui thread.
The logging API relies on the Handler to abstract away the details. Currently there is no AsyncFileHandler included in the JDK so you have to make one or find a 3rd party lib to provide one. E.G. Tomcat JULI.
You can build one from the source code included here: Using java.util.logger with a separate thread to write on file?

jmehrens
- 10,580
- 1
- 38
- 47