CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2009
    Posts
    10

    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!

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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"
    Last edited by Igor Vartanov; August 6th, 2009 at 10:49 AM.
    Best regards,
    Igor

  3. #3
    Join Date
    Aug 2009
    Posts
    10

    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!

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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.
    Best regards,
    Igor

  5. #5
    Join Date
    Aug 2009
    Posts
    10

    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!

  6. #6
    Join Date
    Aug 2009
    Posts
    10

    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!

  7. #7
    Join Date
    Aug 2009
    Posts
    10

    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!

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Add new event log without .NET framework

    Here's the sample.
    Attached Files Attached Files
    Last edited by Igor Vartanov; August 7th, 2009 at 09:25 AM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured