Add new event log without .NET framework
Hello,
I want to create a new Event log to the windows service EventLog and add new logs to it.
By default,the event logs are Application,System and Security but I want to
add a new one.
I could successfully add logs to the Application event log using
RegisterEventSource and ReportEvent functions but I could not find how
to create a new Event log. All the forums discuss this issue using .NET
framework, but I do not want to add the libraries of the .NET.
How can I add a new event log using ONLY mfc?
Thank you in advance!
Re: Add new event log without .NET framework
Well, it's something like:
Code:
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\My Application]
"Sources"=hex(7):4d,79,20,41,70,70,20,44,69,61,67,6e,6f,73,74,69,63,73,00,00
"DisplayNameFile"="C:\\Program Files\\MyApp\\MyApp.dll"
"DisplayNameID"=dword:00000100
"MaxSize"=dword:01000000
"PrimaryModule"="MyApp"
"Retention"=dword:00000000
"File"="C:\\Program Files\\MyApp\\MyApp.evt"
Re: Add new event log without .NET framework
Thank you for your fast response!
Sorry,but can you give me some more details because I am amateur in this field.
Regards!
Re: Add new event log without .NET framework
What is your exact problem? You are not familiar with reg files, or something else?
Try to read about Eventlog Key in MSDN.
Re: Add new event log without .NET framework
Actually, I was not familiar with reg files but now I am ;)
So, do I have to import this file in the windows registry using mfc functions?
Thanks in advance!
Re: Add new event log without .NET framework
I have successfully created a key in the registry, named MyAppDiagnostics, under the tree:
HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Services -> Eventlog
The MyAppDiagnostics contains the key MyApp which has the EventMessageFile and the TypesSupported values. So, the tree is actually:
HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Services -> Eventlog -> MyAppDiagnostics -> MyApp
Then, I run the RegisterEventSource(NULL, "MyApp") but there is no new entry log with the MyAppDiagnostics name is created. Also, when I fire new events, these are added in the Application entry log according to Event Viewer.
How can I create the MyAppDiagnostics entry log and how can I fire events in this entry?
Thank you in advance!
Re: Add new event log without .NET framework
Half of the problem solved!
In order to see the new event log,just restart the Event Viewer software (sometimes I want to crash my head on the desk... :)
But still the events coming from MyApp source are added in the Application Log and not in my new custom log. How can I solve this?
Thanks!
1 Attachment(s)
Re: Add new event log without .NET framework