【问题标题】:Logging to windows event using Pantheios logging library使用 Pantheios 日志库记录到 windows 事件
【发布时间】:2012-01-26 09:25:17
【问题描述】:

如何使用 Pantheios 将日志消息发送到 Windows 事件日志?

如果我使用 Pantheious 从多个进程中执行此操作,它会是进程吗 安全的?会不会摔倒?

【问题讨论】:

    标签: logging pantheios


    【解决方案1】:

    您需要执行以下操作:

    1. 您需要与 be.WindowsEventLog 链接。
      在 Windows 上,这可以通过将 #include <pantheios/implicit_link/be.WindowsEventLog.h> 添加到您的编译单元之一来通过隐式链接来完成。

    2. 此外,您必须定义应用程序特定函数 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;
    }
    

    categoryeventID 的文档可以分别在 MSDN Event Logging docs herehere 上找到。

    【讨论】:

      【解决方案2】:
      1. 使用 be.WindowsEventLog。

      2. 不,我不相信,就像您使用来自多个进程的事件日志一样。

      【讨论】:

        猜你喜欢
        • 2011-02-27
        • 2018-02-20
        • 2018-02-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多