안드로이드 스튜디오에서는 총 5가지의 로그 종류가 있으며 그 종류는 다음과 같다.
Log의 종류 | 의미 | 내용 |
---|---|---|
Log.d() | debug | 개발에 필요한 내용을 출력하기 위해 사용(개발자용) |
Log.i() | information | 일반적인 메세지를 전달하기 위해 사용 |
Log.e() | error | 실제 에러 메시지를 출력하기 위해 사용 |
Log.v() | verbose | 상세한 로그 내용을 출력하기 위해 사용 |
Log.w() | warning | 에러는 아니지만 경고성 메시지를 전달하기 위해 사용 |
원문에서는 다음과 같이 설명한다.
stackoverflow에서 어느 개발자가 설명한 각 Log의 용도는 다음과 같다.
- Log.e: This is for when bad stuff happens. Use this tag in places like inside a catch statement. You know that an error has occurred and therefore you're logging an error.
- Log.w: Use this when you suspect something shady is going on. You may not be completely in full on error mode, but maybe you recovered from some unexpected behavior. Basically, use this to log stuff you didn't expect to happen but isn't necessarily an error. Kind of like a "hey, this happened, and it's weird, we should look into it."
- Log.i: Use this to post useful information to the log. For example: that you have successfully connected to a server. Basically use it to report successes.
- Log.d: Use this for debugging purposes. If you want to print out a bunch of messages so you can log the exact flow of your program, use this. If you want to keep a log of variable values, use this.
- Log.v: Use this when you want to go absolutely nuts with your logging. If for some reason you've decided to log every little thing in a particular part of your app, use the Log.v tag.
And as a bonus...
- Log.wtf: Use this when stuff goes absolutely, horribly, holy-crap wrong. You know those catch blocks where you're catching errors that you never should get...yeah, if you wanna log them use Log.wtf