4

Anybody knows how to implement database exception logging using EL 5.0?

Thanks!

fcartu
  • 355
  • 1
  • 9
  • 20

3 Answers3

4

You will need to run a script against the database so that it creates a specific table structure for you. Also, there will be a stored procedure that will be created that you will have to reference in the Trace Listener's configuration section. You should be able to find this script file here: C:\EntLib41Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts folder. I know this is for version 4 of the library, but looking into the version 5, I realized that the folder structure has taken a change and the script folder is no where in sight. However, this site here should provide you with some guidance.

You may also try MSDN Documentation


So I did a little bit more investigation into the mysterious disappearance of the EntLib50Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts folder. What it turn out to be is that if you had install the Entlib5 to your computer using the MSI like I did. There is actually a Source Code MSI that you can run, buried deep in the C:\Program Files (x86)\Microsoft Enterprise Library 5.0\src if you're using a 64bit pc or C:\Program Files\Microsoft Enterprise Library 5.0\src if you're not. Run this MSI and it will install the the source codes for Entlib5 and also the missing Scripts folder.

Curtis
  • 51
  • 1
  • 4
0

Have you walked through the hands on tutorial? They have a section dedicated to each feature of the enterprise library, including exception logging. http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=6932

Odnxe
  • 644
  • 1
  • 6
  • 19
  • 1
    Hi Odnxe, i read the hands on labs but in this labs there is no mention of exception handling using database. I try to configure the config file, but i do not know if i need to create a store procedure or a table or what i need to create to make it work? – fcartu Aug 10 '11 at 13:48
0

Step one: configure the logging block to log to the database. There's a lab for that. Step two: Configure the exception block to log exceptions. There's a lab for that. Step three: Point the exception block at the logging category that writes to the database.

That's it. There's nothing special about logging exceptions to the database. The exception block will write to the logging block. The logging block treats these just like it would any other logging operation. Follow the instructions for setting up database logging and you're basically done.

Chris Tavares
  • 29,165
  • 4
  • 46
  • 63
  • Hi Chris, i configured all the step that you said, and the application run without problems, but when i check the database table, there is no record. I'm using Oracle Database and i change the sql script from sql server to oracle, i do not know if this can affect something. – fcartu Aug 16 '11 at 23:28
  • The Entlib team has never supported using the database trace listener against anything other than Sql Server. My suggestion would be to try calling the logging sprocs you've configured directly and see if things show up in the table then. When you've got that part working without the blocks in the picture, work your way up to the logging block (which should just work at that point). – Chris Tavares Aug 16 '11 at 23:53
  • Chris, i try calling the sprocs and it works fine. The problem is when i call the ExceptionPolicy.HandleException(e, "UIPolicy"); the app does not throw any error or exception, it execute normally but in the database there is nothing save. – fcartu Aug 17 '11 at 13:20
  • 1
    Did you try using the logging block (without the exception block)? I strongly suspect your issue is in the logging setup, not the exception block. – Chris Tavares Aug 20 '11 at 17:49