Is it possible to log using only TraceListeners with out creating any category?

Topics: Logging Application Block
Jul 24, 2009 at 10:58 AM
Edited Jul 24, 2009 at 11:15 AM

Is it possible to log using only TraceListeners with out creating any catergory?

For ex In the code:

            LogEntry le = new LogEntry();
            le.Categories.Add("DBCategory");
            le.Message = "Testing Logging Message";
            le.EventId = 1111;
            le.Title = "Title";
            le.Priority = 1;
            Logger.Write(le);

In the above code, Category : ' DBCategory' is added.

Is it possible to log with out this?

If am going to comment that in the code ,in Event log (added FormattedEventLogTraceListener in Logging Errors & Warnings) am getting error stating "There is no explicit mapping for the categories".

 

Jul 27, 2009 at 2:18 AM

You can set the DefaultCategory property of the Logging Application Block.  The effect would be all calls to Logger.Write without indicating the category to use would result to logging using the tracelistener(s) included in the default category.

 

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

Jul 28, 2009 at 6:25 AM

Thanks Sarah...