android – 减少ORMlite的内部日志详细程度或禁用它

我们正在我们的应用程序中进行一些重要的性能调整,因此我们开始使用方法跟踪来找到瓶颈.

乍一看,Ormlite很好,但是我们发现,例如在一个需要8ms的查询中,Ormlite的内部日志需要6ms(75%).此外,这些日志调用处于DEBUG级别.

目前我尝试(没有成功)将日志级别设置为ERROR:

>使用adb:adb shell setprop log.tag.Ormlite ERROR
>使用logback:< logger name =“com.j256.ormlite”level =“ERROR”/>

这是logcat的几行

I/System.out( 4207): 2014-10-01 10:50:14,702 [DEBUG] BaseMappedStatement query-for-id using ...
I/System.out( 4207): 2014-10-01 10:50:14,706 [DEBUG] StatementExecutor executing raw query for ...
I/System.out( 4207): 2014-10-01 10:50:14,709 [DEBUG] SelectIterator starting iterator  @-1593957304 for ...
I/System.out( 4207): 2014-10-01 10:50:14,711 [DEBUG] SelectIterator closed iterator @-1593957304 after 1 rows
I/System.out( 4207): 2014-10-01 10:50:14,714 [DEBUG] BaseMappedStatement query-for-id using ...
I/System.out( 4207): 2014-10-01 10:50:14,717 [DEBUG] BaseMappedStatement query-for-id using ...
I/System.out( 4207): 2014-10-01 10:50:14,718 [DEBUG] StatementBuilder built statement ...
I/System.out( 4207): 2014-10-01 10:50:14,719 [DEBUG] BaseMappedStatement prepared statement ...

这是一个方法跟踪的screnshot

有关如何解决这个问题的任何想法?

解决方法

通过方法跟踪,我们看到正在使用LocalLog.正如 LocalLog’s文档中所述:

You can set the log level by setting the System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY,
“trace”).
Acceptable values are: TRACE,DEBUG,INFO,WARN,ERROR,and FATAL.

我们无法使用adb shell设置属性,因此我们将以下行添加到Application.onCreate中

System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY,"ERROR");

最后,我们停止在logcat上看到Ormlite输出,并且性能按预期增加.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...