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

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

Enterprise Library 3.1 database logging

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net

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.

View Complete Post

More Related Resource Links

Help- Enterprise Library Logging Block (Database trace listener)



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.







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?

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.

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" />

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.






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

MVC + Enterprise Library


Not a MVC specific question, but as that's what I'm doing I thought I'll post here.

While looking into the source code of an existing application, I stumbled upon MS Enterprise Library, and as I only heard about these "application block" stuff decided to look into it.

From the theory it sounds like a pretty usefull thing and it made me wonder if other's are using it succesfully along with MVC projects (I know they are not really related!)?

Pro's and Con's? 

I like the database block, as I did not get to any real database development the last 1.5 years, for instance. (Bad excuse I know).  Having an IoC thrown in there (Unity) sounds like I can pretty much stop using 3rd party libraries like I do now all over the place.

Using Enterprise Library for first time



I wan to use the enterprise library for the first time. Is there any samples, quick start guide or ebook is available for a quick start and learn the basics.

I have vs2008, so which version of EL should I use?

And if somebody can just brief about Enterprise Library. Because as per my understanding, is this a mixture of design patterns and some pre-made blocks of source code.





Logging to database is not working



Am using Enterprise library 4.0 for logging exceptions to SQL server database. The code is working fine if I run my asp.net application from the Visual studio IDE.However if I publish the site and host it on IIS, then my application is not logging the errors to database.Here is the page load event of my application.Kindly help me in finding out the error.

Thanks in advance


 protected void Page_Load(object sender, EventArgs e)
                //If exception occurs due to unauthorized access
                if ((Request.QueryString["Unauthorized"] != null) && (Request.QueryString["Unauthorized"].Equals("Y")))
                        lblErrorMessage.Text = "You are not authorized to view this page";
                        //Get the user and machine names                       
                        string strUserName = User.Identity.Name;
                        string strMachineName = System.Environment.MachineName;
                        //Raise Error
                        throw new System.UnauthorizedAccessException("Unauthorized access--User Name:" + strUserName + "--Machine Name:" + 

Enterprise Library: Take Exception To Critical Errors With Custom Application Blocks


Enterprise Library is a collection of application functionality blocks that you can re-use in your application for common functionality you'd otherwise have to write again and again. Here Jay Hilyard explains how to use them.

Jay Hilyard

MSDN Magazine September 2006

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

Debugging Tool: Build a Logging and Event Viewing Library to Help Debug Your .NET Framework-based Ap


Building a basic, reusable application framework can make development quicker and easier. This allows you to focus more on the problems at hand and less on the repetitive tasks involved in building any application. In this article, the author presents a framework that provides facilities to access the registry and an extensible framework for logging messages to a console window or the Event Viewer. This reusable framework can be included as a library in your projects, allowing you to display an enhanced, color-coded message log and dynamically change logging levels.

Daryn Kiely

MSDN Magazine May 2003

Using SQL Server 2008 R2 client with Enterprise Library



I am modifying an existing application that uses SQL Server 2008 as the database and Enterprise Library 4.1 for Data Access .

What I need to do is to make it use the SQL Server 2008 R2 client to take advantage of out of the box failover capabilities.

Any idea how I can accomplish this?


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