Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

App.LogEvent error -2147024882 (System Error &H80004005 (-2147467259).

Status
Not open for further replies.

StevieK

Programmer
Jul 18, 2001
25
0
0
GB
Hi all,

I knocked up a project and decided to use App.LogEvent to log errors, so I set up the event log:

Code:
    Call App.StartLogging(sUnusedFileName, vbLogToNT)

... So that I could then log event information (arbitrary strings) to the Windows NT Event Log by doing:

Code:
    Call App.LogEvent("Some useful event information", vbLogEventTypeInformation)

Unfortunately, when I called App.LogEvent, it raised Runtime Error -2147024882 (System Error &H80004005 (-2147467259). )

After hitting Google, I figured out that -2147024882 occurs when someone does not have access to a particular resource. This could suggest that I didn't have write permission to the Windows EventLog, but I knew that wasn't the case, and that's when the solution hit me like a bolt of lightening:

On Windows XP Professional:
[ol]
[li]Select "Start"->"Run"[/li]
[li]Open "compmgmt.msc" (The Computer Management Console)[/li]
[li]Expand "System Tools"[/li]
[li]Expand "Event Viewer"[/li]
[li]Right-Click on "Application"[/li]
[li]Select "Clear all events"[/li]
[/ol]

Simple, really.

n.b. You'll get the opportunity to save the Event Log to an Event Log File (*.evt), or a Tab- or Comma-delimmited text file if you're worried about losing all your Windows event history. If you export to *.evt you can import the events back into the Event Viewer at a later time to view them.

[Alternatively, if you Right-Click on "Application" in the Event Viewer and select "Properties" you can increase the size of the event log that Windows will keep and/or set it to "Overwrite events as needed", etc.]

Note, if you want backwards compatibility with Windows9x, you should use the following call to start your event log:

Code:
    Call App.StartLogging(sWindows9xLogFileName, vbLogAuto)

... where <sWindows9xLogFileName> is the path to a text file which events will be written to, instead of the NT Event Log. The use of <vbLogAuto> means that event logging will be sent to the NT Event Log on NT-stream computers, or put in a text file on Windows 9x. If you want to foce event logging to be done to a text file use:

Code:
    Call App.StartLogging(sFileName, vbLogToFile)

... Which sends events to the specified textfile, even on NT-stream computers.

Stephen King
Systems Developer and Support Analyst
Infoplex Ltd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top