ormlite android jar,android使用orm框架ormlite在控制台打印log日志信息

在默认情况下,在android下默认只打印info级别的日志信息,所以在默认情况只能打印ormlite中创建数据库表的语句,而对于数据的插入和查询等sql语句是不会打印出来的。在ormlite中提供了 AndroidLog类来设置adb log的级别。因为我们需要打印出更多的sql语句,这样方便我们进行调试。

官网上是这样说明的:

The ormlite-android.jar classes de ne the AndroidLog class which is the Android

speci c version of ORMLite logging. This class makes calls to the Log.d, Log.i, . . .

methods in the Android API. To see the log output, you will need to use the adb utility to

view the log output:

adb logcat

Since INFO is the default under Android, only message such as the following will be spit

out by default:

I/TableUtils( 254): creating table ‘simpledata‘

I/TableUtils( 254): creating index ‘simpledata_string_idx‘ for table

‘simpledata

I/TableUtils( 254): executed create table statement changed 1 rows:

CREATE TABLE `simpledata` (`date` VARCHAR, `id` INTEGER PRIMARY

KEY AUTOINCREMENT , `even` SMALLINT )

I/TableUtils( 254): executed create table statement changed 1 rows:

CREATE INDEX `simpledata_string_idx` ON `simpledata` ( `string` )

To enable more debug information you will want to do something like the following to

turn on logging for a particular class:

adb shell setprop log.tag.StatementExecutor VERBOSE

adb shell setprop log.tag.BaseMappedStatement VERBOSE

adb shell setprop log.tag.MappedCreate VERBOSE

This enables messages such as:

D/BaseMappedStatement(465): create object using ‘INSERT INTO `simpledata`

(`date` ,`string` ,`millis` ,`even` ) VALUES (?,?,?,?)‘ and 4 args,

changed 1 rows

D/BaseMappedStatement(465): assigned id ‘9‘ from keyholder to ‘id‘ in

SimpleData object

To enable all debug messages for all ORMLite classes then use the following:

adb shell setprop log.tag.ORMLite DEBUG

NOTE: Unfortunately, Android property names are limited in size so the ORMLite logger

only takes that last 23 [sic] characters of the class name if it is larger than 23 characters.

For example, if the class is AndroidDatabaseConnection you would do:

adb shell setprop log.tag.droidDatabaseConnection VERBOSE

If you are trying to track operations performed to the database by ORMLite use:

adb shell setprop log.tag.droidDatabaseConnection VERBOSE

adb shell setprop log.tag.ndroidCompiledStatement VERBOSE

也就是说要在后台打印输出更多的日志信息,在项目启动的过程中在adb控制台输入:adb shell setprop log.tag.ORMLite DEBUG即可解决

368f09ed1eae63940e2cf1f6e05ce824.png

原文:http://blog.csdn.net/chonggaoing/article/details/21451835

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值