Logging events with C++ in Event Viewer with TEventLogger

1.1k Views Asked by At

I want to make a log with errors during the execution of my app. I'm trying to write an event to the windows Event Viewer with a VCL form application with C++ Builder XE5. I'm using Vcl.SvcMgr.TEventLogger class. The code in the header file is :

TEventLogger *Event;

The code in the cpp file is :

Event=new TEventLogger("MySource"); 
Event->LogMessage("MyMessage");

But beside my message, in the error description in the Event Viewer there is a message : "The description for Event ID 0 from source MySource cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted." . How can I remove that description and write only the message that I want? Should I be using other C++ class? I couldn't find any documentation about this class. The idea of using Event Viewer is that when the application is running on an user with restricted rights he won't be able to write to files, meaning I can't just type into a ".txt" file. If anyone else has a different idea how to make a log with errors, please share! :)

Thanks in advance, Zdravko

1

There are 1 best solutions below

1
On

This message normally shows up if there is no message files set up within your application. In contrast to Unix syslog and similar logging packages, the Windows event log normally combines messages from the message file and the text you want to log and if there is no message file set up and registered, the event view complains about it.