English subtitles

← Logging on Android - Developing Android Apps

Get Embed Code
10 Languages

Showing Revision 15 created 05/24/2016 by Udacity Robot.

  1. When you're logging a message in your app, you need
  2. to determine what log level it should be displayed at.
  3. Verbose logs should never be compiled into your app, except
  4. during development. Debug logs are compiled in, but they're stripped
  5. out at run time. Error, warn, and info logs are
  6. all kept. And this is what the logging API looks
  7. like. The first parameter is the log tag, which can
  8. be any string that you want to identify the log message.
  9. It's good practice to define the log tag as a
  10. constant in your class. Usually it's the name of your class
  11. or the app. The second parameter is the actual log
  12. message. If we go back to monitor, we can see that
  13. this is the log tag column and this is where
  14. the log message is. If you click on this drop down
  15. here you can filter the logs by log level. For example
  16. you can click on Error to see all the error messages.
  17. If you click on warn, you'll see all the warning
  18. messages as well as anything more severe than that. The
  19. same goes for the other levels. And verbose means that
  20. you can see all the logs at all log levels.
  21. As a PROTIP, you should avoid log spam for your sake and
  22. the sake of other developers. The log buffer could fill up and important
  23. error messages that you really need to see will either roll of the
  24. logs or it will get lost in the sea of unimportant log messages.