How to save Categories only?

Topics: Logging Application Block
Jan 7, 2012 at 2:29 AM

Hello Guyz,

In Logging to a Database, it uses tables Category, CategoryLog and Log. Also with the stored procedures AddCategory, ClearLogs, InsertCategoryLog and WriteLog. When using AddCategory procedure it requires the parameters CategoryID and LogID and calls InsertCategoryLog. Are this procedures called during the LogEntry only? Would it be possible to save only the Categories? How?


Jan 8, 2012 at 7:34 AM

The Database TraceListener calls the WriteLog and AddCategory stored procedures when data is logged.  

So you just want to log the distinct category names?  You don't want to log the messages?  Or you don't care what category the message belongs to?

If you wanted to do that you could modify the stored procedures.  Basically change WriteLog to not insert a record always return a value (e.g. 1) and then modify AddCategory to not call InsertCategoryLog.

I feel like I'm not 100% understanding the scenario -- if you explain the scenario in more detail perhaps we can provide more details?

Randy Levy
Enterprise Library support engineer 

Jan 9, 2012 at 12:40 AM

hello. thanks for the reply.

I just want to save distinct category names in table Category. 

If AddCategory procedure can be modified to not call InsertCategoryLog, what will happen during logging of data? Can the data be logged knowing that this procedure is modified?

Jan 9, 2012 at 12:49 AM
Edited Jan 9, 2012 at 12:54 AM

If you only modify the AddCategory stored procedure and remove the InsertCategoryLog call:

  • You will still have the data logged in the Log table.  
  • You will still have the distinct category names in the Category table
  • You won't know what entry in the Log table is associated with which category

So you only lose the ability to match the Log entry to the Category.  If you don't care about what category a Log entry belongs to then not calling InsertCategoryLog will not affect the ability to save the Log entries or Categories.

Randy Levy
Enterprise Library Support Engineer


Jan 9, 2012 at 1:44 AM

Ok. Thanks for pointing out what will happen if AddCategory procedure is modified and InsertCategoryLog is removed.

Is there any way that I can save only the Categories in table Category table without losing the ability to match the Log entry to the Category? Because I am having this process to save only Categories and a separate process that will save log for a particular Category. 

Jan 9, 2012 at 11:34 PM

I'm afraid I'm not following what you are trying to do.  Can you explain what you are trying to accomplish and how you are thinking of doing it?


Randy Levy
Enterprise Library support engineer