.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Help- Enterprise Library Logging Block (Database trace listener)

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


I'm new to enterprise application blocks. I'm trying to use database trace listener to write the logs to Database. Can someone help me on this .

I would apprciate your response.







View Complete Post

More Related Resource Links

Database Trace Listener in the Enterprise Library doesnt work


I am having a problem on the Database Trace Listener in the Enterprise Library. I have created the database trace listener and and the procedures and tables, but the data is not logged in the table.  Thank you very much.

I need to log data in file and db both. If i comment the database listener, the file listener works but it doesnt work with the database listener. And the database listener doesnt work in any case. Connection string has no problem.

Here's my web.config:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="GeneralLog" logWarningsWhenNoCategoriesMatch="true">
      <add databaseInstanceName="WEBJunctionDbServer" writeLogStoredProcName="WriteLog"
          addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=, Culture=neutral, PublicKeyToken=null"
          traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Form

Using the ConsoleTraceListener with the Enterprise Library 3.1 Logging Block


I'm new to using the Logging application block.  I think I have a pretty good handle on how things work.  However, I'm running into a problem.  I'm using the RollingFlatFileListener and I have formatted the logging template to be more like the logging we are replacing.  However, in our console apps when the ConsoleTraceListener is added it still logs it out in the default text template format.  Is there any way to get around this?  Currently it looks like I will have to create a new TraceListener called FormattedConsoleListener that allows a text formatter to be associated with it.  Is this the only way?

Enterprise Library 3.1 database logging


Im new in using Microsoft Enterprise Library 3.1. Im trying to run database Logging.
I added the required configuration to the web config as mentioned in MSDN library. then I ran the script to generate logging tables and stored procedures.

I changed the formatter template to keep needed data. below is sample of my code

Dim ologEntry As LogEntry = New LogEntry()
        With ologEntry
            .Severity = Diagnostics.TraceEventType.Error
            .Title = "MSEntLib3.1"
            .AppDomainName = AppDomain.CurrentDomain.BaseDirectory
            .ProcessName = "TestFunction()"
            .Message = "Informational message"
        End With


I faced an error that there are missing paramters then I modified writeLog stored Procedure to recieve the listed above paramaters, I test it on sql server its working fine, in my web page it doesnt rais an error and not inserting any data to the log table.

Microsoft Enterprise Library 5.0 - Logging Application Block Activation Error


Hi folks,

I've been writing a class where I wanted to write the errors off to the OS EventLog. I was pointed towards the Logging Application Block. I used LogWriter successfully in a web page and transfer the code to the class so that I could have the functionality there.

I keep getting an {"Activation error occured while trying to get instance of type LogWriter, key \"\""} Error when I reach this line of code:

private LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

I had something similar with the daab getinstance call but I added the unity assemblies to the code and this resolved this. I thought this was the issue with this problem.

Could anyone tell me what I'm doing wrong?

Thanks in advance folks.

app.config code:


<?xml version="1.0" encoding="utf-8" ?>
        <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" />

Data Truncation issue with Enterprise Library Logging WriteLog stored Proc


Hi ,

I'm using Enterprise Library Logging  feature for logging. The issue i am facing is when the Logging message is too large(more than 65534 chars) ,complete data  is not logged in the Formatted Mesage column which is  of data Type nText .

I am able insert complete data if i try inserting from Sql insert Query from sql management studio. Do i need to add any attributes to data base listener or do i need to change the sp.

 Is there any way to increase the WriteLog stored proc param size in EnterpriseLibrary.Logging config file ? . Please let me know.


Thanks In Advance.

Data Points: The Enterprise Library Data Access Application Block, Part 3


E nterprise applications can have a wide variety of data update requirements. Sometimes you need to save multiple rows of changes at once within a single transaction. Other times, the user must be allowed to enter multiple rows of data, send them to the database in a batch; and if a row or two fails, only the rows that succeeded should be committed and remain committed.

John Papa

MSDN Magazine October 2005

Data Points: The Enterprise Library Data Access Application Block, Part 2


Last month I explored the foundation of the Enterprise Library Data Access Application Block (DAAB) including how it all fits into an architecture (see Data Points: The Enterprise Library Data Access Application Block, Part 1).

John Papa

MSDN Magazine August 2005

Data Points: The Enterprise Library Data Access Application Block, Part 1


A solid data access later (DAL) can benefit an application by hiding redundant tasks, helping handle exceptions more gracefully, helping clean up resources more efficiently, and providing a layer of abstraction from the database.

John Papa

MSDN Magazine July 2005

Enterprise library exception block

Hi experts, I am developing an application in two database Oracle & Sql Server, but i want to implement common Exception Handling for both dbs using Enterprise library please suggest me if possible   Thanks in advance

Using Enterprise Library 5.0 Validation Block with Linq to SQL classes


Could anyone show me how to configure the Enterprise Library 5.0 Validation Block with Linq to SQL classes?

How to load "Database Instance" for "Database Trace Listener" at runtime



I have been searching for a while now without success. On how when using EntLib 5.0 Logging, Data; to be able to set the database (i.e. the connection string) at runtime for a Database Trace Listener. The reason being we will have the same configurations on all levels of the environments (dev, test, stage, prod), but the connection string is different for each and we do not store the connection string data in the config file. The connection string data is loaded using a custom configuration manager for security reasons.


Any help and any code sample much appreciated. 



how to write wrapper for Data block of Enterprise library




I have the following scenario.

The project has 4 layers

1) Business Entities

2)Business Layer


all are separate projects
so lets say

1 )Business Entities has

public class Employee
public int EmpId{get;set;}
public string EmpName{get;set}
pullic int Age{get;set;}

2)Business layer will call dataacess layer

public class BusinessLayer

public int RegisterEmployee(Employee objEmp)
 Datalayer objDal =new Datalayer();


3)From the datalayer i need to call Wrapper for enterprise library and the requirement is
datalayer should not have any reference of Enterprise library data block(that i dont know how to do that)
Only the wrapper class should have reference for Enterprise library data block


public class Datalayer
 public int AddEmployee(Employee objEmp)
///Database db=DatabaseFactor.Createdatabase()
//the above line should not be in datalayer it should in some other componenent
//lets say component is wrapper
//i want to how to write wrapper for that.
//As well as how to build command and parameter



VseWSS 1.3 Deployment error related to Enterprise LIbrary(Exception Handling block)


We are getting the folllowing error while deploying VseWSS 1.3. There seems to be an issue with Exception Handling Block.

There no more detail in log file except for this error as shown below. We did a complete reinstall of VS 2008 and VseWSS and Enterprise Library, but the error persist.

Is there some incompatibility issue with VseWSS 1.3 and EL? Has anyone come across this error before:



Microsoft.SharePoint.Tools.Utilities.VSeWSSServiceException: VSeWSS Service Error: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, CommonErrorPolicy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)


Log fil

Enterprise Library 4 Asynchronus logging


Hi All,

I am desiging an application in whcih I need to use EntLib 4 and for error logging I have to use Async method. Can any one please tell me how can I use EntLib 4 for asynchronus logging? need urgent help.

Please suggest.

Logging logevents to flat file using Microsoft Enterprise Library



I Want to log logevents to text file using Microsoft enterprise library, but i could not find any decant tutorial for same.

If you guys have any tutorial or link, please pass it to me.






Add Stack Trace in trace.log file using Enterprise library 5.0



I am facing one issue while using trace.log file for logging the exceptions. I need to get the stack trace with other exception information. But stack trace is not available with provide enterprise library 5.0 exception logging template. Is there any way I can add this.

Also I want to genrate seprate trace.log file for every day.


Scale Up Enterprise Library Caching Application Block


CAB from MS is a very famous tool for the developers as it saves a lot of valuable time of the developers. But anyone who has decided to use CAB, should also keep into mind its limitations as well. The cache in EnltLib is stand alone and in-process in nature that’s why it can ends up with some scalability and reliability issues when used in a multi-server environment. But there are some party integrations which can over come this issue. The most popular way to overcome these limitations of CAB is the use of a distributed cache. The article about the drawbacks of CAB and it solutions can be a very helpful read in this regard. 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend