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}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
source to share
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.
source to share