Logging Application Block To MOM

Topics: Logging Application Block
Jul 23, 2009 at 11:27 AM

Hi I need to log my exceptions to MOM.

 

I am trying to log in to Event Viewer using the follwoing code:

                    LogEntry _logentry = new LogEntry();
                    _logentry.Categories.Add("EventLogCategory");
                    _logentry.Priority = 2;
                    _logentry.EventId = 4000;
                    _logentry.Severity = TraceEventType.Information;
                    _logentry.Title = "My Title";
                    _logentry.Message = "Message from Log Entry Object";
                    Logger.Write(_logentry);
                    Logger.Write("This is being written to text file", "DebugCategory", 2, 2000, TraceEventType.Information, "My method");    

 I have configured the Enterprise Lib Conofg and have added it to the solution as app.config.

When I debug I can see logentry object having all the values from the cofnig file. But it does not write into Event Viwer

 

Can anyone pls help.

Jul 23, 2009 at 11:38 AM

What is your OS? From what type of project does this code executes?  Is it a class library?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jul 23, 2009 at 11:53 AM

- its a Windws Server 2003, 64 bit box.

I have added this code to a button click event - eventually it wud be part of the class lib

 

Thanks

Jul 23, 2009 at 12:01 PM

Most likely, it's a permission issue as by default, permissions are more strict in a win2003 environment.  Refer to this thread - http://entlib.codeplex.com/Thread/View.aspx?ThreadId=56632.  Also make sure that  your app.config is in the executable that references the class library, not in the class library itself.  Most people expect to have their configuration file in a class library if their Logger.Write codes are in a class inside a class library project.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jul 23, 2009 at 12:22 PM

Even i was wondering -

when i use EventLog.CreateEventSource(__eventLogSource, __eventLogName); i am able to create  a log folder.

 But I am not able to write .

is there anyways I can chk the permissoions?

 

Thanks

 

 

Jul 23, 2009 at 12:27 PM

You can check it here - http://support.microsoft.com/kb/323076.  It's mentioned in the thread I posted above.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Jul 23, 2009 at 12:37 PM

oo Thanks a lot, I wud check -

Just to extend, if there anyways I can directly write the logs into MOM server or Event Viwere is meant for that.

Thanks.

Jul 23, 2009 at 12:59 PM

There's no out-of-the-box tracelisteners built for it.  I'm not familiar with MOM but as long as there's an API for directly writing to it, it would be easy to create a custom tracelistener.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com