can we create our own Event Viewer from the config file of Enterprise Library?

Topics: Logging Application Block
Aug 10, 2009 at 5:02 AM
Edited Aug 10, 2009 at 5:33 AM

Is there is any possibility to create our own Event viewer type category(ex: like "Application") from the config file?

Plz let me know if that is possible...

Aug 10, 2009 at 6:24 AM

Hi,

Are trying to achieve something like this: http://entlib.codeplex.com/Thread/View.aspx?ThreadId=54413 / http://entlib.codeplex.com/Thread/View.aspx?ThreadId=45365?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 10, 2009 at 6:36 AM
Edited Aug 10, 2009 at 6:57 AM

Thanks for the replay..

My requirement is not like this : Creating the Event log is not using the code.

It should be from the conguration file using our own event log.

 

Aug 10, 2009 at 6:47 AM

If I understand you correctly, you asking if there is a facility in the config tool of enterprise library that automatically creates a  event log? Do I got it right?

Aug 10, 2009 at 7:00 AM

Yes .. Its like that only..

Is it possible?

Please let me know..

Aug 10, 2009 at 7:05 AM

It is not possible. A way that i could think of is create the event log thru code or manually.

Aug 10, 2009 at 3:13 PM

Couple of notes regarding the event log.  First it requires Administrative privileges to create event log sources. Secondly, event log sources should be created before attempting to write to them.  The MSDN documentation states that if you create the event log source and attempt to write to it right away, it could result in event log corruption. The event log source requires a bit of time (a second or two?) to initialize itself.

To create event log source via PowerShell, you can use:

 

$machineName = '.'

[System.Diagnostics.EventLog]::CreateEventSource('My Application Source', 'Application', $machineName)

 

or from .NET code,

string sourceName = "My Application Source";
string logName = "Application";
string machineName = "."; // local machine
System.Diagnostics.EventLog.CreateEventSource( sourceName, logName, machineName);


madhulatha wrote:

Thanks for the replay..

My requirement is not like this : Creating the Event log is not using the code.

It should be from the conguration file using our own event log.