Add-Ons & Services

Event Log Display

Please post support and help requests here.
Posts: 2
Joined: 23 Feb 2010, 19:38

Event Log Display

Postby ericzhill » 23 Feb 2010, 20:57

I'm using the EventLogChannel to send messages into the Windows event log. The events are showing up in the event log, but without displaying the logged message.

The event log source in the event log is "Learning", which lines up nicely with the property in the Learning.properties file. The message, however, is completely blank. If I remove the registry key under HKLM\System\CurrentControlSet\Services\EventLog\Application\Learning that signifies the PocoFoundation.dll, the event viewer displays the usual "The description for Event ID 4096 from source Learning cannot be found" message, followed by the insertion string I would expect.

The documentation (http://pocoproject.org/poco/docs/Poco.EventLogChannel.html) says "To work properly, the EventLogChannel class requires that either the PocoFoundation.dll or the PocoMsg.dll Dynamic Link Library containing the message definition resources can be found in $PATH.", and I've used both the PocoFoundation.dll and PocoFoundationd.dll with the same blank results. I cannot seem to locate PocoMsg.dll on my computer, though I've found the pocomsg.rc and associated BIN file under Foundation/src, but I'm not sure how to turn those into a dll.

FWIW, I see the same problem on a Windows 7 machine using Visual Studio 2008, and a Windows XP machine using Visual C++ Express.

Any suggestions on what I'm missing?

Here's a sample app that I'm using to test...


Code: Select all

logging.loggers.eventlog.channel.class = EventLogChannel
logging.loggers.eventlog.channel.name = Learning
logging.loggers.eventlog.channel.logfile = Application
logging.loggers.eventlog.level = debug

logging.loggers.console.channel.class = ConsoleChannel
logging.loggers.console.channel.pattern = %s: [%p] %t
logging.loggers.console.level = debug

application.logger = eventlog


Code: Select all

#include <vector>
#include <string>
#include <iostream>

#include <Poco/Util/Application.h>

using std::vector;
using std::string;
using std::cout;
using std::endl;
using Poco::Util::Application;

class SampleApp : public Application {
   virtual int main(const vector<string>& args);
   virtual void initialize(Application& self);


Code: Select all

#include "main.cpp"

int SampleApp::main(const vector<string>& args) {
   logger().debug("This is a debug message");
   return 0;

void SampleApp::initialize(Application& self) {



Posts: 2
Joined: 23 Feb 2010, 19:38

Re: Event Log Display

Postby ericzhill » 24 Feb 2010, 00:41

Figured it out, though I still think there's a problem in the Poco build system somewhere. The PocoMsg.mc should have been built into the PocoFoundation.dll, but it wasn't. I took the following steps to manually produce a PocoMsg.dll that I could register with the event viewer system and it works exactly as expected.

This is the rough process we need to go through to get the pocomsg.mc file turned into its own dll:

Code: Select all

                        /  |  \
                       /   |   \
  pocomsg.h <---------+    |    +---------> msg0001.bin
      ^                    |                    ^
      |                    |                    |
      |                    v                    |
  pocomsg.cpp          pocomsg.rc --------------+
      |                    |
      |                    |
   <cl.exe>             <rc.exe>
      |                    |
      |                    |
      v                    v
  pocomsg.obj          pocomsg.res
      |                    |
      |                    |
      +---- <link.exe> ----+

First, we need an empty "boiler-plate" DLL entry point. Create pocomsg.cpp with the following contents:

Code: Select all

#include "windows.h"

extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
   return (TRUE);

Next, we use mc to produce the header, rc script, and binary message file. Then we compile the rc script to a res file. Last, we compile the cpp file (that includes the generated header) to an object and link the object and resource files together to produce the dll.

Code: Select all

mc.exe PocoMsg.mc
rc.exe PocoMsg.rc
cl.exe /c PocoMsg.cpp
link /dll /machine:ix86 PocoMsg.obj PocoMsg.res

Here is how it looks on my system:

Code: Select all

 Volume in drive C has no label.
 Volume Serial Number is C437-076E

 Directory of C:\Libs\poco-1.3.6p1\PocoMsg

02/23/2010  03:13 PM    <DIR>          .
02/23/2010  03:13 PM    <DIR>          ..
02/23/2010  01:05 PM               135 PocoMsg.cpp
12/21/2009  07:12 PM             2,475 PocoMsg.mc
               2 File(s)          2,610 bytes
               2 Dir(s)  105,542,844,416 bytes free

C:\Libs\poco-1.3.6p1\PocoMsg>mc PocoMsg.mc
MC: Compiling PocoMsg.mc

C:\Libs\poco-1.3.6p1\PocoMsg>rc PocoMsg.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.

C:\Libs\poco-1.3.6p1\PocoMsg>cl /c PocoMsg.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.


C:\Libs\poco-1.3.6p1\PocoMsg>link /dll /machine:ix86 PocoMsg.obj PocoMsg.res
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

 Volume in drive C has no label.
 Volume Serial Number is C437-076E

 Directory of C:\Libs\poco-1.3.6p1\PocoMsg

02/23/2010  03:15 PM    <DIR>          .
02/23/2010  03:15 PM    <DIR>          ..
02/23/2010  03:14 PM               232 MSG00001.bin
02/23/2010  01:05 PM               135 PocoMsg.cpp
02/23/2010  03:15 PM            41,472 PocoMsg.dll
02/23/2010  03:14 PM             3,758 PocoMsg.h
12/21/2009  07:12 PM             2,475 PocoMsg.mc
02/23/2010  03:14 PM               547 PocoMsg.obj
02/23/2010  03:14 PM                39 PocoMsg.rc
02/23/2010  03:14 PM               296 PocoMsg.res
               8 File(s)         48,954 bytes
               2 Dir(s)  105,542,500,352 bytes free


Posts: 5
Joined: 07 Nov 2011, 17:17

Re: Event Log Display

Postby PaulThexton » 09 Nov 2011, 19:31

Sorry to dredge up an old thread like this, but I have followed what was outlined here to produce a PocoMsg.dll file. However, it does not seem to matter where I copy the resulting dll file to (anywhere in the standard system $PATH), I still have messages in my windows EventLog that essentially say that the resource etc could not be found. I can still see my log messages, so it's not the end of the world, it just doesn't look "clean".

It could be because my POCO app is running as a windows service, and thus the $PATH is different I suppose. I'm relatively sure that once upon a time there was a wiki for POCO that had useful tips for things like this on it, but it appears to have vanished :( (or I'm not looking hard enough).

Posts: 5
Joined: 07 Nov 2011, 17:17

Re: Event Log Display

Postby PaulThexton » 10 Nov 2011, 12:05

Ok - to help people out who may have been having the same problem.

If you have run your application without a PocoMsg.dll (or PocoFoundation.dll) available in your application's path, and then tried to do so subsequently with those files available, this will still not work until you first remove the entry HKLM\System\CurrentControlSet\Services\Eventlog\Application\{your app name}

The EventLogChannel code creates the key it needs without first checking if it can find the required resource file. On first run, without the resource being available, this results in the key being created but no strings are contained in it. On subsequent runs, with a resource available, the code cannot follow the path of execution to set these strings up as the call to create the key fails (key already exists), which means you can end up chasing your tail trying to work out why your dll file containing the messages is still not being used.

May I suggest to the POCO developers (if they're reading this) that on failure to locate a resource file after creating a key, then the key should be removed. Or maybe, check the value populated in to disposition for REG_OPENED_EXISTING_KEY, so that the strings inside the key may be updated/created as necessary.

Posts: 3
Joined: 14 Dec 2012, 14:33

Re: Event Log Display

Postby faburaya » 03 Mar 2013, 07:18

Well, I tried everything here. I built the PocoMsg.dll and put it in the $PATH (as ericzhill demonstrated), and removed the folder with my application name in the registry (as PaulThexton said). Ran the application again: Same thing. I still have the same error message in the events registered in the Windows event log. Maybe there is some code missing in pocomsg.cpp when I built the DLL, maybe I should change something in the registry, but I have no clue what. Does anyone have an idea what should I try next?

*Obs: My system is a Windows 8 x64. I have this problem when running either 32 or 64 bits applications using POCO foundation logging facilities. The output in the log is:

Code: Select all

The description for Event ID 4096 from source 3FD Application Tests cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

2013-Mar-03 02:04:39 [36] - Priority is 'Error' in thread 216.    Message [Third exception.] @ Function [application_tests::f1] File [Application Tests.cpp] Line [107] >> Call stack trace: { Application Tests.cpp (143) @ application_tests::Framework_RTM_TestCase_L03_NormalUsage_Test_Test::TestBody,Application Tests.cpp (99) @ application_tests::f1 } # Details: "I happenned as a consequence of the second."

the message resource is present but the message is not found in the string/message table

Posts: 1200
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Event Log Display

Postby alex » 04 Mar 2013, 14:41

Probably some sort of Windows 8 (which we have not tested thoroughly yet) peculiarity. Best to submit a GitHub issue.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 3 guests