Multiple Listeners

Topics: Logging Application Block
Nov 10, 2008 at 10:22 PM
Edited Nov 10, 2008 at 10:23 PM
Hi,

            I am very beginner using enterprise library. I am preparing sample application using logging application block. I am able to configure and write events to flat file. Now i am developing sample application to write inforation into data base using logging application block. I want to write the information into event log when  data base insertion fails. So i created two listeners, one for data base second for event log.

            Now the problem how i can refer the particular listner in my code.
              Ex:  where i need to mention in code write informqation into event log or data base.....


Can you please help me on this? Really appreciate if any sample code...

Thanks
RP
Nov 11, 2008 at 1:06 AM
You just need to specify the category.  For example, if you're FlatFile TraceListener is under the General category, your log entry should have something like this:

LogEntry entry = new LogEntry();
entry.Categories.Add("General");

and if the Database TraceListener is under the Audit category:

LogEntry entry = new LogEntry();
entry.Categories.Add("Audit");



Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 11, 2008 at 4:21 PM
Hi Sarah,

              Thank you very much for your quick response and  explanation. My issue is i want to write the log information into data base with category "General". I want to write into event log with category "General"  when an error whilw inserting log information into data base. Inthis case my category is same. I am sure, i missing something. Can you please advice me on this?

Thanks in advance
Ravi
Nov 12, 2008 at 2:09 AM
See this thread... http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=39482


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