【发布时间】:2012-01-26 09:25:17
【问题描述】:
如何使用 Pantheios 将日志消息发送到 Windows 事件日志?
和
如果我使用 Pantheious 从多个进程中执行此操作,它会是进程吗 安全的?会不会摔倒?
【问题讨论】:
如何使用 Pantheios 将日志消息发送到 Windows 事件日志?
和
如果我使用 Pantheious 从多个进程中执行此操作,它会是进程吗 安全的?会不会摔倒?
【问题讨论】:
您需要执行以下操作:
您需要与 be.WindowsEventLog 链接。
在 Windows 上,这可以通过将 #include <pantheios/implicit_link/be.WindowsEventLog.h> 添加到您的编译单元之一来通过隐式链接来完成。
此外,您必须定义应用程序特定函数 pantheios_be_WindowsEventLog_calcCategoryAndEventId()(如 docs 中的 tiny 注释中所指定:注意这是应用程序指定的功能..
一个例子,简单的实现可以在pantheios-folder\test\scratch\test.scratch.api\test.scratch.api.cpp找到:
// The following allows this to be used with the Windows EventLog back-end.
PANTHEIOS_CALL(void) pantheios_be_WindowsEventLog_calcCategoryAndEventId(
int /* backEndId */
, int /* severity */
, pantheios::uint16_t* category
, pantheios::uint32_t* eventId
) /* throw() */
{
// NOTE: A proper implementation would specify non-0 values here that
// identify the requisite event identifier and category within the
// associated message file(s).
*eventId = 0;
*category = 0;
}
category 和 eventID 的文档可以分别在 MSDN Event Logging docs here 和 here 上找到。
【讨论】:
使用 be.WindowsEventLog。
不,我不相信,就像您使用来自多个进程的事件日志一样。
【讨论】: