0

I'm having a problem with making my VB.NET application point to something rather than "Application" in Event Log...

I create my custom event log using the function: EventLog.CreateEventSource("My_Source_Name", "My_Log_Name") where the first parm is the Source Name, and the second parm is the log name. This method works every time it creates the event log's source, but when I'm about to add a new entry, I'm surprised that for some sources the process write the log under my custom log, but for other sources, the log is written in Application!!! (Some times with an error at it's header)!!!!!

I need to know, what exactly is going on?? am I (somehow) following the right way?? if Yes, what are the enhancements that I need to add to my code to make it look much better?? how can I stop this from occurring again so I can have all my logs under my customized log name?? and if No, what is the right way of doing this?? and is there any other way of writing this code (even if the new code was for another solution rather than the event log)??

Thank you very much :)

Anas Mousa
  • 23
  • 1
  • 5

1 Answers1

0

"To create an event source in Windows Vista and later or Windows Server 2003, you must have administrative privileges."

http://msdn.microsoft.com/en-us/library/5zbwd3s3.aspx

On the other hand, you should have a class (or interface) in charge of logging as a vertical layer on your application. That class is the one in charge of internally write to the appropriate event source.

However, if you need something powerful I really recommend Log4Net.

http://logging.apache.org/log4net/

Oscar
  • 13,594
  • 8
  • 47
  • 75
  • Although it's a bit late, but Thank you for your answer :) I checked if the user we use in our job is an administrator or have administrator privileges, and yes, it has administrator's privileges. Also, I went to your link on msdn, and from it, I got an idea of checking the event source if it's in under my log name or not, and I executed that solution, and I got some of them out of my log name, so I returned them back, but the weird thing is: they are still under Application!!! So, any idea why?? and how to fix it?? – Anas Mousa May 16 '13 at 09:08
  • One more thing, regarding Log4Net, unfortunately, we can't use any non-Microsoft programs since we are under a contract with Microsoft. Plus, every time we have to setup our solution, we have to have Log4Net on the machine we are installing our application on, and that's unlike the case with the already Built-in Event Log.... so for us, that won't work.... sorry :( – Anas Mousa May 16 '13 at 09:13