【WCE】使用事件日志服务(四)

本文介绍了如何将SQL Mobile的事件记录到Windows CE的Application日志中,包括设置环境变量、修改注册表、更新项目配置、生成系统映象并创建测试项目进行调试的过程。在调试过程中,详细展示了事件日志服务初始化的日志信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

*《【WCE】使用事件日志服务(三 / 四)》的内容已重新调整过。

假设我们要记录一个事件源是 SQL Mobile 的事件到 Application 日志。需要如下步骤:

1. 使用菜单 Platform->Settings,在“Platform Settings”对话框中选择“Environment”标签,设置环境变量 SET PRJ_ENABLE_EVENTLOG = 1。

2. 在 project.reg 添加:

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/EventLog/Application]
 "Output"="File"
 "File"="ApplicationLog.xml"
 "Format"="XML"

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/EventLog/Application/SQL Mobile]
 "EventMessageFile"="sqlce30ermsgs.dll"

3. 在 project.bib 添加:

MODULES
;  Name            Path                                           Memory Type
;  --------------  ---------------------------------------------  -----------
 sqlce30ermsgs.dll $(_FLATRELEASEDIR)/sqlce30ermsgs.dll   NK SH

其中,sqlce30ermsgs.dll 是笔者编写的 SQLCE 3.0 的错误事件消息文件。

4. 执行 SYSGEN,生成新的操作系统映象,下载映象到模拟器。

5. 创建一个用于测试的 VC++ 2005 Win32 Smart Device Project,并命名为 reportevt:

int _tmain(int argc, _TCHAR* argv[])
{
    HANDLE hEventLog(RegisterEventSource(NULL, TEXT(
"SQL Mobile")));
    ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, 
00xC0000E00, NULL, 00, NULL, NULL);
    DeregisterEventSource(hEventLog);
    
return 0;
}

6. 使用刚才的模拟器调试 reportevt,可得调试输出信息:

4294768076 PID:43fc8c1a TID:43fc8bea 0x83fc8a3c: >>> Loading module eventlog.dll at address 0x03750000-0x0376B000 (RW data at 0x01F74000-0x01F748B4)
...
4294768116 PID:43fc8c1a TID:43fc8bea 0x83fc8a3c: EventLog:: EventLogInit() called
...
4294768746 PID:43fc8c1a TID:43fc8bea 0x83fc8a3c: EventLog:: EventLogStart(szDestinationFolder=/windows/) called
...
4294768896 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: EventLogWorkerThread() initiated
4294768896 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: System supports UTF8.  EventLog will write log files in this format.
4294768906 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: Begin loading up format and outputter extensions
4294768936 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: Done loading up format and outputter extensions.
4294768946 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: About to initialize eventLogger for <System>
4294768966 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: Initialized file log /windows/SystemLog.xml, maxLog size = 32768
4294768976 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: EventLog <<System>> successfully initialized.
4294768976 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: About to initialize eventLogger for <Application>
4294768986 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: Initialized file log /windows/ApplicationLog.xml, maxLog size = 32768
4294768986 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: EventLog <<Application>> successfully initialized.
...
4294768996 PID:43fc8c1a TID:63fae7c2 0x83fca800: >>> Loading module eventlogmsgs.dll at address 0x03740000-0x03743000
...
4294769006 PID:43fc8c1a TID:63fae7c2 0x83fca800: EventLog: Printing out initial EventLog startup messages to EventLog log
...
 268100 PID:3bf2a2e TID:3beae56 0x83bea800: >>> Loading module reportevt.exe at address 0x16010000-0x1602D000
...
 268160 PID:3bf2a2e TID:3beae56 0x83bea800: InitSharedHeap: 44300000 0 c
 268160 PID:3bf2a2e TID:3beae56 0x83bea800:   InitSharedHeap: return 44300060
 268210 PID:43fc8c1a TID:3beae56 0x83bea800: >>> Loading module sqlce30ermsgs.dll at address 0x01DF0000-0x01E04000
...
 268330 PID:3bf2a2e TID:3beae56 0x83bea800: <<< Unloading module ole32.dll at address 0x03700000-0x03739000 (RW data at 0x01F70000-0x01F71520)
 268340 PID:3bf2a2e TID:3beae56 0x83bea800: <<< Unloading module reportevt.exe at address 0x16010000-0x1602D000
...
 268390 PID:3bf2a2e TID:3beae56 0x83bea800: <<< Unloading module coredll.dll at address 0x03F50000-0x03FF3000 (RW data at 0x01FFE000-0x01FFF765)

以及日志文件 ApplicationLog.xml:

<evt  type="错误" d="2007-8-2" t="21:19:54" s="SQL Mobile" c="无" id="3221229056" msg="取值函数无效。[,,,,,]"/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值