记录消息
在 IBM RPA Studio 控制台或 IBM RPA Control Center上记录消息。 如果需要,还可将消息记录到 Windows 事件日志。
IBM RPA Studio 的机器人执行会在该相同工具的控制台上记录消息。 其余将在 IBM RPA Control Center上运行日志消息。
语法
logMessage --message(String) --type(EventType) [--logonwindows(Boolean)] [--logname(String)] [--source(String)] [--eventid(Numeric)]
输入参数
下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。
| 设计器方式标签 | 脚本方式名称 | 必需的 | 接受的变量类型 | 描述 |
|---|---|---|---|---|
| 消息 | message |
Required |
Text |
要作为输出返回的消息。 |
| 类型 | type |
Required |
EventType |
所记录消息的事件类型。 有关接受哪些类型的更多信息,请参阅 type 参数选项。注:类型对应于 Windows 事件查看器上的日志记录级别。 要使用此功能,请启用登录 Windows 事件参数。
|
| 在 Windows 事件日志上记录 | logonwindows |
Optional |
Boolean |
允许在 Windows 事件日志上记录消息的选项,该消息会显示在 Windows 事件查看器上。 |
| 日志 | logname |
Optional. Visible only if logonwindows is enabled |
Text |
在 Windows 事件查看器上记录事件的日志名称。 有关更多信息,请参阅 logname 参数选项。 |
| 源 | source |
Optional. Visible only if logonwindows is enabled |
Text |
与生成事件日志的应用程序对应的源,这必须是 Windows 中的现有应用程序。 注:如果未定义任何数据,那么缺省值为 "应用程序"。
|
| 事件标识 | eventid |
Optional. Visible only if logonwindows is enabled |
Number |
Windows 事件查看器上事件日志的标识号。 |
type 参数选项
下表显示了可用于 type 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | 描述 |
|---|---|---|
| 错误 | Error |
错误是已记录消息所适用的事件类型。 |
| 信息 | Info |
信息是已记录消息所适用的事件类型。 |
| 警告 | Warning |
警告是已记录消息所适用的事件类型。 |
logname 参数选项
下表显示了可用于 logname 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | 描述 |
|---|---|---|
| 应用程序 | application |
该消息在 Windows 事件查看器中记录为应用程序日志。 |
| 安全 | safety |
该消息在 Windows 事件查看器中记录为安全日志记录。 |
| 配置 | configuration |
该消息在 Windows 事件查看器中记录为配置日志。 |
| 系统 | system |
该消息在 Windows 事件查看器中记录为系统日志。 |
| 转发的事件数 | eventsforwarded |
该消息在 Windows 事件查看器中记录为已转发事件日志。 |
示例
示例 1:显示直接写入消息参数的消息。
logMessage --message "Execution occurred without errors!\r\n" --type "Info"
// Return the following output on the console:
// "Execution occurred without errors!"
示例 2:显示变量“numericValue”的内容以及信息文本“The contents of the variable 'numericValue' is:”。
defVar --name numericValue --type Numeric --value 100
logMessage --message "The content of the variable \"numericValue\" is: ${numericValue}" --type "Info"
// Return the following output on the console:
// The content of the variable 'numericValue' is: 100
示例 3:在“应用程序”日志中显示 Windows 事件查看器上记录的“错误”文本消息。
logMessage --message "Execution occurred with errors and will be logged on the Windows Event Viewer." --type "Error" --logonwindows --logname Application --source Application --eventid 2019
// Return the following output on the console:
// [Error] Execution has occurred with errors and will be logged on the Windows Event Viewer.
注:根据 消息 参数中信息的排列,将遵循换行符和间距。