安卓Log.v(),Log.d(),Log.i(),Log.w(),Log.e() - 当使用每一个?Log

2023-09-11 12:50:30 作者:杯酒过喉

不同的 LogCat中方法是:

Log.v(); // Verbose
Log.d(); // Debug
Log.i(); // Info
Log.w(); // Warning
Log.e(); // Error

什么是适当的场合使用的每个类型的日志记录?我知道,也许这就是语义的只是一点点,也许这并不重要,但对于 LogCat中过滤在Eclipse中,这将是很好知道我现在用的是适当的方法在适当的时间。

What are the appropriate situations to use each type of Logging? I know that perhaps it's just a little bit of semantics and perhaps it doesn't really matter, but for LogCat filtering in Eclipse, it would be nice to know I am using the proper methods at the appropriate times.

推荐答案

让我们以相反的顺序:

Log.e :这是当不好的事情发生。使用的地方这个标签就像里面捉说明书。您的知道的已经发生了错误,因此你记录一个错误。

Log.e: This is for when bad stuff happens. Use this tag in places like inside a catch statment. You know that an error has occurred and therefore you're logging an error.

Log.w :当你怀疑什么见不得人的事情,请使用此。你可能不完全充满的错误模式,但也许你从一些意外的行为恢复。基本上,用它来记录你的东西,没想到会发生,但并不一定是一个错误。有点像嘿,这发生了,它的怪异,我们应该考虑它。

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 :使用此张贴有用的信息到日志中。例如:您已成功连接到服务器。基本上用它来报告成功。

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 :使用此进行调试。如果你想打印出一堆邮件,因此您可以登录你的程序的具体流程,使用此。如果您想保留日志变量的值,用这个。

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 :当你想要去的绝对坚果与您的日志记录使用此功能。如果由于某种原因你决定记录每一件小事,在你的应用程序的特定部分,使用Log.v标签。

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 :使用此当东西去绝对,可怕的,圣洁的,废话错误的。你知道那些catch块,你正在追赶你的错误从来没有的应该......是啊,如果你想登录他们使用Log.wtf 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...yea, if you wanna log them use Log.wtf
 
精彩推荐
图片推荐