Registration in the enterprise library. Database trace listener with custom parameter input

I have a log table in Oracle Oracle and support for a proc stored procedure that takes the following inputs and sends them to a table with the same columns.

PROCEDURE     SP_LOG_INSERT
   ( ProgramDate  Varchar2  ,
     ProgramName   date ,
     ProgramStatus varchar2,
     ProgramMessage varachar2(4000 Byte))

      

how to populate the table using these custom options using enterprise libaray 5.0. I've seen many online pages, but most of them suggest creating a new table and a new stored procedure. I even referenced a blog by Alex Oliver here , which was really helpful. But I want to use an existing table and stored procedure. Is it possible to do this or should I create a new table and stored procedure. Below is my TextFormatter

<formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
        name="Text Formatter" />
    </formatters>

      

enter image description here

+3


source to share


1 answer


You will need to create your own trace listener that knows how to log into your table / stored procedure, or modify the log table / stored procedure in the format that an enterprise library expects.

Here is a sample database trace listener for SQL Server. This might be a good starting point for you if you decide to create a custom trace listener.



Also, since you are using Oracle, you will need to change the database script (as it depends on SQL Server). The Ultimate Guide to Enterprise Library 5.0 Application Logging Block Using Oracle 11g is a nice blog post on setting up database logging with Oracle.

+2


source







All Articles