My question seems to be easily answerable, but there are several good solutions. I like to choose the 'best' one.
logger.debug("Some log message. Details: {}", someObject.toString());
is a good, and effective way to skip string concatenations if the logger is turned off; lightweight logger binding that delegates to android.util.Log
.com.example.myapp.MyClass
tag translated to c*.e*.m*.MyClass
), which can result in the same log tag for different classes (e.g., com.example.app.MyClass
and com.example.anotherapp.MyClass
both translate to c*.e*.a*.MyClass
); No built in crash reporting system.Besides of these, I like Androlog behavior, but I'm a Java dev, familiar with log4j/slf4j. We will definitely need crash report system, but there are several frameworks for crash reporting (beside of android default crash report).
I can combine some of them, for example use Log4J android, but create an appender to use the androlog framework, but sooner or later it will be a mess, which should be avoided.
Thanks for your suggestions, I hope the results will help decide others in the future.
Edit: As mentioned below, I can combine for ex: log4j-android with slf4j (whitch I prefer to do if I'll use log4j, because the log formatting support ("{}",...) ), but it does not answers the question. I have to choose a framework, then I can decorate it with the SLF4J facade.
The Log. d() method is used to log debug messages. The Log. i() method is used to log informational messages.
The better way. I think, is to use SLF4J API + some of its implementation.
For Android applications you can use the following:
Please check this first answer
It says:
SLF4J is basically an abstraction layer. It is not a logging implementation. It means that if you're writing a library and you use SLF4J, you can give that library to someone else to use and they can choose which logging implementation to use with SLF4J e.g. log4j or the Java logging API. It helps prevent projects from being dependent on lots of logging APIs just because they use libraries that are dependent on them.
So, to summarise: SLF4J does not replace log4j, they work together. It removes the dependency on log4j from your library/app.
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