wilsond has asked for the wisdom of the Perl Monks concerning the following question:
I "fixed" it by making a messages dll. See below for info on how I went about it. It looks complicated, but it's really not difficult.
Does anyone know a way to write to the event log without this error embedded in the log?
Here is the anonymized event log entry example:
Event Type: Information Event Source: MyAppName Event Category: None Event ID: 0 Date: 1/20/2009 Time: 1:28:16 AM User: N/A Computer: COMPUTER-NAME Description: The description for Event ID ( 0 ) in Source ( MyAppName ) cannot be f +ound. The local computer may not have the necessary registry informat +ion or message DLL files to display messages from a remote computer. +You may be able to use the /AUXSOURCE= flag to retrieve this descript +ion; see Help and Support for details. The following information is p +art of the event: This is a test log entry..
I've already found "Write to WIndows Event Log", but it doesn't really answer the question for me. I could use the WSH method, but I want my application's name to show up as the source, not "WSH". I can't use Win32::EventLog::Message because the version provided by Dave Roth doesn't support ActivePerl 5.10 and doesn't look like it ever will. Win32::EventLog::Message seems like the right answer, but too bad about the version problem.
Here is a sample of the code that I'm currently using to write the log:
use Win32::EventLog; my $eventlog = Win32::EventLog->new('MyAppName'); $eventlog->Report({ EventType => EVENTLOG_INFORMATION_TYPE, Strings => qq(This is a test log entry.), });
Even using the test case included with the module (at http://cpansearch.perl.org/src/JDB/Win32-EventLog-0.076/t/eventlog.t) fails in the same way.
Here's what I did to make it work for me:
MessageIdTypedef=WORD LanguageNames=(English=0x409:MSG00409) MessageId=0x0 Severity=Success Facility=Application SymbolicName=CATEGORY_SUCCESS Language=English %1 .
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Applica +tion\MyAppName] "TypesSupported"=dword:00000007 "CustomSource"=dword:00000001 "EventMessageFile"="C:\\the-location-that-your-eventlog.dll-will-be-in +stalled\\EventLog.dll"
use Win32::EventLog; my $eventLog = Win32::EventLog->new('MyAppName'); $eventLog->Report({ EventType => EVENTLOG_INFORMATION_TYPE, Strings => 'This is a test log entry.', }); $eventLog->Close();
| While I ask a lot of Win32 questions, I hate Windows with a passion. That's the problem with writing a cross-platform program. I'm a Linux user myself. I wish more people were. |
| If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so. |
| - Richard Dawkins |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Write to Win32 Event Log, get "/AUXSOURCE=" error
by BrowserUk (Patriarch) on Jan 20, 2009 at 12:52 UTC | |
by wilsond (Scribe) on Jan 21, 2009 at 06:01 UTC | |
by wilsond (Scribe) on Jan 21, 2009 at 06:54 UTC |