Decrease ORMlite's internal log verbosity or disable it

人走茶凉 提交于 2019-12-01 04:18:01

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

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.

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");

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

For me I used ORMLite in my project (not with android). there I used the logback.xml to configure it.

http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_5.html

If that class is not found it then looks for org.apache.log4j.Logger and if found will use Log4j.

So we can simply use logback.xml as bellow.

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="com.my.test" level="TRACE" additivity="false">
        <appender-ref ref="STDOUT" />
    </logger>

    <root level="INFO">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!