Log.d和对性能的影响 [英] Log.d and impact on performance
问题描述
我不能完全确定什么我读的文件中。它是确定留下一堆log.d件code错落,或者我应该把它们注释掉,这样他们就不会影响我的应用程序的性能。
I'm not entirely sure about what I'm reading in the documentation. Is it ok to leave a bunch of log.d pieces of code scattered about, or should I comment them out so that they don't impact my app's performance.
谢谢
我有点困惑,因为如果你阅读有关的日志对象(文档)你看到这一点:
I'm a little confused because if you read about the log object (documentation) you see this:
,在详细程度方面的顺序,从最低到最高为ERROR,WARN, INFO,DEBUG,冗长。冗长不应该被编译成 除了应用程序开发过程中。调试日志中编译,但 在运行时剥离。错误,警告和信息日志始终保持。
"The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept. "
这几乎听起来像它的确定要离开调试消息在那里,因为他们是剥夺。无论如何,感谢您的答案,我会发表评论,他们出来的时候,我做了。不象我需要他们在那里,一旦应用程序就完成了。
It almost sounded like it's ok to leave debug messages in there because they are "stripped." Anyway, thanks for the answers, I'll comment them out when I'm done. Not like I need them in there once the app is completed.
感谢
推荐答案
日志对性能的影响,所以建议你把它注释掉或记录与条件语句。
Log has impact on performance, so it's recommended that you comment it out or log with conditional statements.
例如
public class MyActivity extends Activity {
// Debugging
private static final String TAG = "MyApp";
private static final boolean D = true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(D) Log.e(TAG, "MyActivity.onCreate debug message");
}
当你发布你的发行版只是改变D为false。然后
Then in when you publish your release version just change "D" to false
这篇关于Log.d和对性能的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!