Create a custom EventLog other than on the Application node in the Windows EventLog (in Delphi)

416 views Asked by At

How create (in Delphi) a custom EventLog other than on the "Application" node in the Windows EventLog?

//The code below write on the Application node only

with TEventLogger.Create('JarvisAgent') do
begin
  try
    try
      LogMessage(Msg, EVENTLOG_INFORMATION_TYPE, 0, 2);
    finally
      Free;
    end;
  except
  end;
end;
1

There are 1 answers

0
Remy Lebeau On BEST ANSWER

TEventLogger uses the older ReportEvent() API for logging messages. For that API, you have to register a custom log file and its supported event source names, event types, etc in the Registry. Then you can create TEventLogger using your registered event source name, and messages will go to your registered log file.

This is all documented on MSDN.

About Event logging

Event Logging Elements

Also see:

Write in Windows-Eventlog with Delphi Event-ID not found

My answer to WinAPI ReportEvent - component not installed.