降低ORMlite的内部日志详细程度或将其禁用 [英] Decrease ORMlite's internal log verbosity or disable it

查看:135
本文介绍了降低ORMlite的内部日志详细程度或将其禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We're doing some heavy performance tuning in our app, hence we start using method tracing to find the bottlenecks.

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

At first glance Ormlite was fine, but we found that for example in one query that takes 8ms, 6ms (75%) were needed by Ormlite's internal log. Futhermore those log call are in DEBUG level.

此刻,我尝试(未成功)通过以下方式将日志级别设置为ERROR:

At the moment I have tried (without success) setting log level to ERROR this way:

  • 与adb:adb shell setprop log.tag.ORMLite ERROR
  • 带登录:<logger name="com.j256.ormlite" level="ERROR"/>
  • with adb: adb shell setprop log.tag.ORMLite ERROR
  • with logback: <logger name="com.j256.ormlite" level="ERROR"/>

这是logcat的几行内容

This are a few lines from the 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 ...

这是方法跟踪的摘要

对如何解决这个问题有任何想法吗?

Any thoughts on how to handle this out?

推荐答案

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

With method tracing we saw that LocalLog was being used. As is stated on LocalLog's documentation:

您可以通过设置System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY, "trace").
可接受的值为:TRACE,DEBUG,INFO,WARN,ERROR和FATAL.

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

We couldn't set the property using adb shell so we added the following line to our Application.onCreate

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

最后,我们不再在logcat上看到ORMLite输出,并且性能按预期提高.

Finally we stop seeing ORMLite output on logcat and performance increased as expected.

这篇关于降低ORMlite的内部日志详细程度或将其禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆