Adding support for new columns in logging database

Topics: Building and extending application blocks, Logging Application Block
Oct 9, 2007 at 2:32 PM

I've added a new column to the CategoryLog table and need to create a custom trace listener that inserts the value. Finding it difficult to track down step-by-step documentation on how to do this. Am I missing something or did I simply code this incorrectly? I've been unable to get this to work.

(1) Created a class faLogEntry that inherits from LogEntry and added in the new column

[Serializable]
[XmlRoot("logEntry")]
public class faLogEntry : LogEntry
{
private string identifier;
public string Identifier
{
get { return this.identifier; }
set { this.identifier = value; }
}
}

(2) Created custom trace listener class that inherits from FormattedDatabaseTraceListener. Modified the ExecuteAddCategoryStoredProcedure method to pass the stored proc the new column value.

[ConfigurationElementType(typeof(FormattedDatabaseTraceListenerData))]
public class faCustomTraceListener : FormattedDatabaseTraceListener
{
private string writeLogStoredProcName = String.Empty;
private string addCategoryStoredProcName = String.Empty;
private Database database;

private string defaultCategory = "General";
private TraceEventType defaultSeverity = TraceEventType.Information;
private int defaultPriority = -1;
private string defaultTitle = "";
private int defaultEventId = 1;

public override void Write(string message)
{
faLogEntry logEntry = new faLogEntry();
logEntry.Message = message;
logEntry.Severity = defaultSeverity;
logEntry.Priority = defaultPriority;
logEntry.Title = defaultTitle;
logEntry.Priority = defaultPriority;
logEntry.EventId = defaultEventId;
logEntry.Categories.Add(defaultCategory);

Write(logEntry);
}

public override void WriteLine(string message)
{
faLogEntry logEntry = new faLogEntry();
logEntry.Message = message;
logEntry.Severity = defaultSeverity;
logEntry.Priority = defaultPriority;
logEntry.Title = defaultTitle;
logEntry.Priority = defaultPriority;
logEntry.EventId = defaultEventId;
logEntry.Categories.Add(defaultCategory);

Write(logEntry);
}

public override void Write(string message, string category)
{
faLogEntry logEntry = new faLogEntry();
logEntry.Message = message;
logEntry.Severity = defaultSeverity;
logEntry.Priority = defaultPriority;
logEntry.Title = defaultTitle;
logEntry.Priority = defaultPriority;
logEntry.EventId = defaultEventId;
logEntry.Categories.Add(category);

Write(logEntry);

}

public override void Write(object o, string category)
{
faLogEntry logEntry = (faLogEntry)o;
logEntry.Categories.Add(category);

Write(logEntry);
}

public override void Write(object o)
{
faLogEntry logEntry = (faLogEntry)o;
ExecuteStoredProcedure(logEntry);
}

public faCustomTraceListener(Database database, string writeLogStoredProcName, string addCategoryStoredProcName, ILogFormatter formatter)
: base(database, writeLogStoredProcName, addCategoryStoredProcName, formatter)
{
this.writeLogStoredProcName = writeLogStoredProcName;
this.addCategoryStoredProcName = addCategoryStoredProcName;
this.database = database;
}

private void ExecuteStoredProcedure(faLogEntry logEntry)
{
using (DbConnection connection = database.CreateConnection())
{
connection.Open();
try
{
using (DbTransaction transaction = connection.BeginTransaction())
{
try
{
int logID = Convert.ToInt32(ExecuteWriteLogStoredProcedure(logEntry, database, transaction));
ExecuteAddCategoryStoredProcedure(logEntry, logID, database, transaction);
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
}
finally
{
connection.Close();
}
}
}

private int ExecuteWriteLogStoredProcedure(faLogEntry logEntry, Database db, DbTransaction transaction)
{
DbCommand cmd = db.GetStoredProcCommand(writeLogStoredProcName);


db.AddInParameter(cmd, "eventID", DbType.Int32, logEntry.EventId);
db.AddInParameter(cmd, "priority", DbType.Int32, logEntry.Priority);
db.AddParameter(cmd, "severity", DbType.String, 32, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.Severity.ToString());
db.AddParameter(cmd, "title", DbType.String, 256, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.Title);
db.AddInParameter(cmd, "timestamp", DbType.DateTime, logEntry.TimeStamp);
db.AddParameter(cmd, "machineName", DbType.String, 32, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.MachineName);
db.AddParameter(cmd, "AppDomainName", DbType.String, 512, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.AppDomainName);
db.AddParameter(cmd, "ProcessID", DbType.String, 256, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.ProcessId);
db.AddParameter(cmd, "ProcessName", DbType.String, 512, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.ProcessName);
db.AddParameter(cmd, "ThreadName", DbType.String, 512, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.ManagedThreadName);
db.AddParameter(cmd, "Win32ThreadId", DbType.String, 128, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.Win32ThreadId);
db.AddParameter(cmd, "message", DbType.String, 1500, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, logEntry.Message);

if (Formatter != null)
db.AddInParameter(cmd, "formattedmessage", DbType.String, Formatter.Format(logEntry));
else
db.AddInParameter(cmd, "formattedmessage", DbType.String, logEntry.Message);

db.AddOutParameter(cmd, "LogId", DbType.Int32, 4);

db.ExecuteNonQuery(cmd, transaction);
int logId = Convert.ToInt32(cmd.Parameters{"[cmd.Parameters.Count - 1]"].Value, CultureInfo.InvariantCulture);
return logId;
}

private void ExecuteAddCategoryStoredProcedure(faLogEntry logEntry, int logID, Database db, DbTransaction transaction)
{
foreach (string category in logEntry.Categories)
{
DbCommand cmd = db.GetStoredProcCommand(addCategoryStoredProcName);
db.AddInParameter(cmd, "categoryName", DbType.String, category);
db.AddInParameter(cmd, "logID", DbType.Int32, logID);
db.AddInParameter(cmd, "identifier", DbType.String, logEntry.Identifier); // THIS IS THE NEW COLUMN I ADDED
db.ExecuteNonQuery(cmd, transaction);
}
}
}

(3) Created CustomTextFormatter to add new column

<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;Identifier: {identifier}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Custom Text Formatter" />

(4) Updated stored procedure InsertCategoryLog to add new column

(5) Add CustomTraceListener to app.config. In the "type" property, select the assembly that contains the faCustomTraceListener class I created in step 2. This is where I receive an error: 'no type found in assembly that inherits from CustomTraceListener'. I've tried changing the class I'm inheriting from FormattedDatabaseTraceListener to CustomTraceListener and get the same message.

Thanks
Jan 18, 2011 at 1:37 PM

I know this is quite old post but I am still interested in the solution of the above post. Did you find answer ?

Jan 18, 2011 at 11:59 PM

You mean in step #5?  You simply need to close and re-open Microsoft Visual Studio.  What happens is that the current domain has already loaded the assembly of the custom database trace listener which initially inherits from the FormattedDatabaseTraceListener.  Even after changing it to CustomTraceListener, when you try to load the assembly in the type picker, it doesn't update the previous assembly and so it still see your custom trace listener inheriting from FormattedDatabaseTraceListener. 

On a different note, the entire steps isn't quite correct.  First, as you have already noticed, it should inherit from CustomTraceListener.  Next is, the ConfigurationElementType specifying FormattedDatabaseTraceListenerData will cause it to still create a FormattedDatabsaeTraceListener rather than your custom trace listener.  Since this looks like the steps wants to have full integration with the configuration tool, you should create a new class inheriting from TraceListenerData and use that class as the type you specify in the ConfigurationElementType attribute.  If you're using version 4.1 and lower , you also need to create a corresponding assembler class.  You can refer to the source code to get an idea.  In EntLib 5.0, assembler classes are no longer needed and writing custom providers is much easier.  This is documented, you can check it out here

 

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

Jan 24, 2011 at 10:48 AM

Hi Sarah,

Thanks for your reply. I am now one step further. The custom trace listener works fine now I am stuck to integrate it with configuration tool. Configuration tool does not recognize this new custom trace listener. When I try to open configuration file with configuration tool I get exception “Invalid TraceListenerData type in the configuration listenerData Type …….”. Am I doing sth. wrong or configuration tool does not support this new type?

By the way I am using version 4.1. I did following so far:

//Create a new trace listener by inheriting from FormattedDatabaseTraceListener

[ConfigurationElementType(typeof(CustomFormattedDatabaseTraceListenerData))]

public class CustomFormattedDatabaseTraceListener : FormattedDatabaseTraceListener

{

//override and implement required methods

}

 

//Create a new CustomFormattedDatabaseTraceListenerData which actually does nothing only inherit all the functionality //from FormattedDatabaseTraceListenerData.

[Assembler(typeof(CustomFormattedDatabaseTraceListenerAssembler))]

[ContainerPolicyCreator(typeof(FormattedDatabaseTraceListenerPolicyCreator))]

public class CustomFormattedDatabaseTraceListenerData : TraceListenerData

{

            //Copy the implementation from FormattedDatabaseTraceListenerData

 }

 

//Create a corresponding assembler class in order to create my custom trace listener

public class CustomFormattedDatabaseTraceListenerAssembler : TraceListenerAsssembler

{

public override TraceListener Assemble(IBuilderContext context,

                                               TraceListenerData objectConfiguration,

                                               IConfigurationSource configurationSource,

                                               ConfigurationReflectionCache reflectionCache)

        {

            CustomFormattedDatabaseTraceListenerData castedObjectConfiguration

                = (CustomFormattedDatabaseTraceListenerData)objectConfiguration;

 

            IBuilderContext databaseContext

                = context.CloneForNewBuild(

                    NamedTypeBuildKey.Make<Microsoft.Practices.EnterpriseLibrary.Data.Database>(castedObjectConfiguration.DatabaseInstanceName), null);

 

            Microsoft.Practices.EnterpriseLibrary.Data.Database database

                = (Microsoft.Practices.EnterpriseLibrary.Data.Database)databaseContext.Strategies.ExecuteBuildUp(databaseContext);

 

            ILogFormatter formatter

                = GetFormatter(context, castedObjectConfiguration.Formatter, configurationSource, reflectionCache);

 

            TraceListener createdObject

                = new CustomFormattedDatabaseTraceListener(

                    database,

                    castedObjectConfiguration.WriteLogStoredProcName,

                    castedObjectConfiguration.AddCategoryStoredProcName,

                    formatter);

 

            return createdObject;

        }

}

 //Configuration settings for my custom trace listener

<add databaseInstanceName="LoggingConnection" writeLogStoredProcName="WriteLog"         addCategoryStoredProcName="AddCategory" formatter="Text Formatter"         listenerDataType=" Logging.Configuration.CustomFormattedDatabaseTraceListenerData, Logging"         traceOutputOptions="None" filter="All" type=" Logging.TraceListeners.CustomFormattedDatabaseTraceListener, Logging" name="Custom Database Trace Listener" />

Jan 25, 2011 at 7:07 AM

What you're trying to do is a basic integration right? If yes, then as what Sarah said, your Custom TraceListener should inherit from the CustomTraceListener class and the ConfigurationElementType should be of type CustomTraceListenerData. Therefore your Custom Trace Listener may look something like this;

using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;


namespace ApplicationBlock_LoggingDrill_Basic
{
    [ConfigurationElementType(typeof(CustomTraceListenerData))]
    public class CustomDBTraceListener : CustomTraceListener
    {

        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
                  if (this.Filter == null || this.Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null))
            {
                if (data is LogEntry && data != null)
                {

                    Database db = DatabaseFactory.CreateDatabase(this.Attributes["Database"]);

                    DbCommand cmd = db.GetStoredProcCommand(this.Attributes["WriteStoredProc"]);


                    LogEntry le = (LogEntry)data;
                    db.AddParameter(cmd, "severity", DbType.String, 32, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, le.Severity.ToString());
                    db.AddInParameter(cmd, "timestamp", DbType.DateTime, le.TimeStamp);
                    db.AddParameter(cmd, "message", DbType.String, 1500, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Default, le.Message);
                    db.AddInParameter(cmd, "ExtendedProperty", DbType.String, System.Security.Principal.WindowsIdentity.GetCurrent().Name);
                    db.AddOutParameter(cmd, "LogId", DbType.Int32, 4);
                    db.ExecuteNonQuery(cmd);
                }
            }
        }

        public override void Write(string message)
        {
            throw new NotImplementedException();
        }

        public override void WriteLine(string message)
        {
            throw new NotImplementedException();
        }
    }
}

And your configuration will be..

<add Database="CustomLogging" WriteStoredProc="CustomWriteToCustomDB"
        Param1="Value1" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="Warning" type="ApplicationBlock_LoggingDrill_Basic.CustomDBTraceListener, ApplicationBlock_LoggingDrill_Basic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
        name="CustomDBTraceListener" initializeData="" formatter="CustomDBMessageFormat" />

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 4, 2011 at 3:35 PM

Thanks Gino/Noel,

I implemented the code as below but I am getting the error which says:

ERROR Message = 

"The type Database cannot be constructed. You must configure the container to supply this value."

CONFIG FILE:

<?xml version="1.0" encoding="utf-8"?>
<configuration>  
    <configSections>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    </configSections>
    <loggingConfiguration name="LoggingApplicationBlock" tracingEnabled="true"
        defaultCategory="General">
        <listeners>           
            <add name="RxCTraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                databaseInstanceName="RxCDatabase" writeLogStoredProcName="GHTR.RxCWriteLogToDB"
                addCategoryStoredProcName="General" />
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.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>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="RxCTraceListener" />
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events" />
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="RxCTraceListener" />
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>
    <dataConfiguration defaultDatabase="RxCDatabase" />
    <connectionStrings>
      <add name="RxCDatabase" connectionString="Data Source=local;Initial Catalog=Employee_Database;Integrated Security=SSPI;"
 providerName="System.Data.SqlClient"/>      
    </connectionStrings>
</configuration>


C# CODE:

using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Formatters;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;
using Microsoft.Practices.EnterpriseLibrary.Data;
using IBM.Data.DB2;
using System.Configuration;
namespace WindowsFormsApplication1
{
    [ConfigurationElementType(typeof(CustomTraceListenerData))]
    public class MyTraceListener:CustomTraceListener
    {                
        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
            //if (data is LogEntry && data != null)
            {

                //Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.ConnectionStrings["RxCDatabase"].ConnectionString);
                //using (var dbConnection = new IBM.Data.DB2.DB2Connection(ConfigurationManager.ConnectionStrings["RxCDatabase"].ConnectionString))
                {
                    try
                    {
                        Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.ConnectionStrings["RxCDatabase"].ConnectionString);

                        //DB2Connection db2Conn = new DB2Connection();
                        DB2Command cmd = new DB2Command("GHTR.RXCWriteLogToDB");
                        cmd.CommandType = CommandType.StoredProcedure;
                        //cmd.CommandType = CommandType.Text;
                        ExtendedLogEntry le = (ExtendedLogEntry)data;

                        //string insertSQL = "INSERT INTO GHTR.RXC_LOG_TEST VALUES(DEFAULT,'" + le.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'," + le.ProgramId + ",'" + le.UserId + "','" + le.MachineName + "'," + le.ThreadId + ",'" + le.Level + "','" + le.Logger + "','" + le.Message
                            //+ "'," + le.JobId + ",'" + le.AddOperId + "','" + le.AddTimeStamp.ToString("yyyy-MM-dd HH:mm:ss.fff") + "','" + le.LastOperId + "','" + le.LastTimeStamp.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'" + ");";


                        //cmd.Parameters.Add(new DB2Parameter("log_TimeStmp",le.TimeStamp));
                        //cmd.Parameters.Add(new DB2Parameter("prog_Id", le.ProgramId));
                        //cmd.Parameters.Add(new DB2Parameter("userId", le.UserId));
                        //cmd.Parameters.Add(new DB2Parameter("machineName", le.MachineName));
                        //cmd.Parameters.Add(new DB2Parameter("threadId", le.ThreadId));
                        //cmd.Parameters.Add(new DB2Parameter("lvl", le.Level));
                        //cmd.Parameters.Add(new DB2Parameter("logger", le.Logger));
                        //cmd.Parameters.Add(new DB2Parameter("msg", le.Message));
                        //cmd.Parameters.Add(new DB2Parameter("job_Id", le.JobId));
                        //cmd.Parameters.Add(new DB2Parameter("add_Oper_Id", le.AddOperId));
                        //cmd.Parameters.Add(new DB2Parameter("add_Time_Stmp", le.AddTimeStamp));
                        //cmd.Parameters.Add(new DB2Parameter("last_Oper_Id", le.LastOperId));
                        //cmd.Parameters.Add(new DB2Parameter("last_Time_Stmp", le.LastTimeStamp));

                        //cmd.CommandText = insertSQL;
                        //dbConnection.Open();
                        //cmd.Connection = dbConnection;
                        //cmd.ExecuteNonQuery();


                        db.AddInParameter(cmd, "log_TimeStmp", DbType.DateTime,  le.TimeStamp);
                        db.AddInParameter(cmd, "prog_Id", DbType.Int32, le.ProgramId);
                        db.AddInParameter(cmd, "userId", DbType.String,  le.UserId);
                        db.AddInParameter(cmd, "machineName", DbType.String, le.MachineName);
                        db.AddInParameter(cmd, "threadId", DbType.String, le.ThreadId);
                        db.AddInParameter(cmd, "lvl", DbType.String,le.Level);
                        db.AddInParameter(cmd, "logger", DbType.DateTime, le.Logger);
                        db.AddInParameter(cmd, "msg", DbType.String, le.Message);
                        db.AddInParameter(cmd, "job_Id", DbType.String, le.JobId);
                        db.AddInParameter(cmd, "add_Oper_Id", DbType.String, le.AddOperId);
                        db.AddInParameter(cmd, "add_Time_Stmp", DbType.DateTime, le.AddTimeStamp);
                        db.AddInParameter(cmd, "last_Oper_Id", DbType.String, le.LastOperId);
                        db.AddInParameter(cmd, "last_Time_Stmp", DbType.DateTime,le.TimeStamp);
                        db.ExecuteNonQuery(cmd);
                    }

                    catch (Exception ex)
                    {
                        
                    }
                }
            }
        }

        public override void Write(string message)
        {
            throw new NotImplementedException();
        }

        public override void WriteLine(string message)
        {
            throw new NotImplementedException();
        }
    }


    public class ExtendedLogEntry : LogEntry
    {

        public DateTime TimeStamp { get; set; }
        public int ProgramId { get; set; }
        public string UserId { get; set; }
        public string MachineName { get; set; }
        public int ThreadId { get; set; }
        public string Level { get; set; }
        public string Logger { get; set; }
        public string Message { get; set; }
        public int JobId { get; set; }
        public string AddOperId { get; set; }
        public DateTime AddTimeStamp { get; set; }
        public string LastOperId { get; set; }
        public DateTime LastTimeStamp { get; set; }
    }


}

Apr 5, 2011 at 2:32 AM

You should simply call

 Database db = DatabaseFactory.CreateDatabase("RxCDatabase");

or Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("RxCDatabase"); //recommended approach in EntLib 5.0

instead of

 Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.ConnectionStrings["RxCDatabase"].ConnectionString);

The parameter to CreateDatabase method is the name of the connection string, not the connection string itself.

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