Logging with MS Enterprise Library 5.0

May 24, 2010 at 9:09 AM
Edited May 24, 2010 at 9:15 AM

can any one explain me how we use the Lib for database logging( i am useing .Net Framework 3.5)

i want mantain logs from website which is developed in ASP.Net using C#

plz explain me step by step (with dummy values) because i am totaly new with MS Enterprise Library 5.0

i already groth through documantation also but i could not able to enter a log in database

thanks for your quick response

May 24, 2010 at 9:16 AM

First run the .sql script that comes with the source code of the enterprise library. This can be found <Drive letter>\EntLib50Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts\CreateLoggingDb.cmd

By default, it will try to install it to a SQLExpress server so if you're using a default instance, right click on the .cmd file and select Edit.  Change the sql server parameter to (local).

In your config file, do the ff(using the config tool):

  1. Add the Logging Application Block.
  2. Add a category (optional, you may use the existing).
  3. Configure a connection string that will use the Logging database that was created by running the script.
  4. Add a Database Trace listener and set the Database Instance property to the connection string you've just created. 

Let me know if anything's unclear.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 24, 2010 at 9:30 AM

i have configured all those which you have mention and i have send a email also with snapshort attachement what i have configure. now what is the next step? and web.config code also sending

  
   
   
  
  
   
  
  
   
    
     
    
   
  
  
   
   
   
    
     
    
   
  
 
 
 
  
  
 
May 24, 2010 at 9:35 AM

What seems to be the problem now? are you encountering a runtime exception?  Or it simply doesn't log?  If it's the latter, change the trace listener under the Logging Errors and Warnings to reference the Event Log Trace Listener rather than the database trace listener.  After running your application, check the event log for any logs indicating what exception occurred while logging to the database.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 24, 2010 at 9:43 AM

first of all i am really thanks for your very quick response

 

_____________________________

LogEntry logEntry = new LogEntry();
        logEntry.EventId = 100;
        logEntry.Priority = 2;
        logEntry.Message = "Informational message";
        logEntry.Categories.Add("Trace");
        logEntry.Categories.Add("UI Events");
        LogWriter myLogWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
        myLogWriter.Write(logEntry);
        
_________________________________

now i am trying execute this code on my page load...its execyting successfully but when i am looking LOGGING database tables i did not find any entry their...i dont know why its not enter the record into database...

now my question is just simply give me the code which i can execute on my page load and its store into my LOGGING database tables.

 

May 24, 2010 at 9:45 AM

That code is supposed to do the logging.  Please try out the suggestion I made on using the Event Log Trace Listener under the Logging Errors and Warnings so we can determine the problem on why it's not logging to the Logging database.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 24, 2010 at 9:55 AM

i have tryed both way but still i did not find any entry into database tables..

please suggest me what i can do now?

May 24, 2010 at 9:58 AM

That suggestion is to diagnose what the problem is, did you check the event viewer for any logs indicating why the logging failed?

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 24, 2010 at 10:02 AM

this is the error which i found in window application log viewers...now what is the solution for it?
Message: There is no explicit mapping for the categories 'Trace, UI Events'. The log entry was: 
Timestamp: 5/24/2010 8:38:34 AM
Message: Informational message
Category: Trace, UI Events
Priority: 2
EventId: 100
Severity: Information
Title:
Machine: QNADEEMLT
App Domain: 1c7b8f8c-5-129191639055140861
ProcessId: 128
Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE
Thread Name: 
Win32 ThreadId:692
Extended Properties: 

Category: 

Priority: -1

EventId: 6352

Severity: Error

Title:

Machine: QNADEEMLT

App Domain: 1c7b8f8c-5-129191639055140861

ProcessId: 128

Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE

Thread Name: 

Win32 ThreadId:692

Extended Properties: 

May 24, 2010 at 10:12 AM

That's it.  You shouldn't be adding Trace and UIEvents to the Categories property collection.  You should be adding "General".  Sorry. should've noticed when you posted your code.  The Categories property collection maps to the categories you defined in your config.  You will only add the category whose referenced trace listeners correspond to the trace listener you want to use.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 24, 2010 at 10:20 AM

i have done this now i am facing new error... the error is following

sorry for you distrubing again and again, i really need to log my website

 

Message: Tracing to LogSource 'General' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.

May 24, 2010 at 10:30 AM

You do have the General category defined in your web.config, right?  I saw that in the web.config you sent but needed to confirm in case you renamed it.

Can you continue reading on with the logged message in the event viewer, I think there are other information included that's more detailed.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

 

May 24, 2010 at 10:43 AM

I have already added the "General" category you can see in web.config file

 

see the detail of error

 

Event Type:	Error
Event Source:	Enterprise Library Logging
Event Category:	None
Event ID:	6352
Date:		5/24/2010
Time:		12:40:37 PM
User:		N/A
Computer:	QNADEEMLT
Description:
Timestamp: 5/24/2010 9:40:37 AM

Message: Tracing to LogSource 'General' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.


Summary for Enterprise Library Distributor Service:
======================================
--> 
Message: 
Timestamp: 5/24/2010 9:40:37 AM
Message: Informational message
Category: General, General
Priority: 2
EventId: 100
Severity: Information
Title:
Machine: QNADEEMLT
App Domain: 1c7b8f8c-9-129191662651380977
ProcessId: 128
Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE
Thread Name: 
Win32 ThreadId:7988
Extended Properties: 
--> MachineName: QNADEEMLT
--> TimeStamp: 5/24/2010 9:40:37 AM
--> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
--> AppDomainName: 1c7b8f8c-9-129191662651380977
--> WindowsIdentity: DEVELOPMENT\qnadeem

Exception Information Details:
======================================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 2812
Procedure: 
Server: SAPPHIRE
State: 62
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: Could not find stored procedure 'WriteLog'.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information Details: 
======================================
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DbCommand command) in e:\Builds\EntLib\Latest\Source\Blocks\Data\Src\Data\Database.cs:line 443
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command, DbTransaction transaction) in e:\Builds\EntLib\Latest\Source\Blocks\Data\Src\Data\Database.cs:line 732
   at Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.ExecuteWriteLogStoredProcedure(LogEntry logEntry, Database db, DbTransaction transaction) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\DatabaseTraceListener\FormattedDatabaseTraceListener.cs:line 244
   at Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.ExecuteStoredProcedure(LogEntry logEntry) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\DatabaseTraceListener\FormattedDatabaseTraceListener.cs:line 156
   at Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\DatabaseTraceListener\FormattedDatabaseTraceListener.cs:line 89
   at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerWrapper.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\Logging\TraceListeners\TraceListenerWrapper.cs:line 92
   at Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\Logging\LogSource.cs:line 180
   at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl.ProcessLog(LogEntry log, TraceEventCache traceEventCache) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\Logging\LogWriterImpl.cs:line 557

Category: 

Priority: -1

EventId: 6352

Severity: Error

Title:

Machine: QNADEEMLT

App Domain: 1c7b8f8c-9-129191662651380977

ProcessId: 128

Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE

Thread Name: 

Win32 ThreadId:7988

Extended Properties: 

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

 

 

May 24, 2010 at 10:46 AM

The error is "Could not find stored procedure 'WriteLog'."  Are you sure you used the correct connection string?  Does the WriteLog stored procedure exists in that database?  Actually I didn't receive the web.config file, you need to zip it before sending.  I only referred to the snapshot.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 24, 2010 at 11:19 AM

Thanks now its working fine.

May 6, 2011 at 10:04 AM

hi Sarah

:(

i am getting error like sp "Loggin" doesn't exists.

i have taken dll's from tutorial, and of-course sp with name "Loggin"  is not required i think.

is it related to connectionstring where db name is loggin?

 

Help..

Thank You

ashwani

May 6, 2011 at 10:22 AM

 

 

Error trace is like this

 

 

Exception Type: System.Data.SqlClient.SqlException Errors: System.Data.SqlClient.SqlErrorCollection Class: 16 LineNumber: 1 Number: 2812 Procedure: Server: ashwani\sqlexpress State: 62 Source: .Net SqlClient Data Provider ErrorCode: -

2146232060 Message: Could not find stored procedure 'Logging'. Data: System.Collections.ListDictionaryInternal TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean) HelpLink: NULL StackTrace Information Details: ====================================== at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.

May 6, 2011 at 10:40 AM

Can you post your config here? It seems that you renamed the sp here. As far as I remember, it should be 'WriteLog'.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 6, 2011 at 11:02 AM

OH i figure out the problem

i was confuse with category option in listener block and replace AddListener with Logging .

 

 

now code is running fine but no log is made in db

error trace like this

 

Message:
Timestamp: 5/6/2011 9:50:57 AM
Message: Informational message
Category: LoggingCategory
Priority: 8
EventId: 9006
Severity: Information
Title:
Machine: ASHWANI
App Domain: 6485ed21-2-129491481241079508
ProcessId: 5384
Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE
Thread Name:
Win32 ThreadId:3676
Extended Properties:
--> MachineName: ASHWANI
--> TimeStamp: 5/6/2011 9:50:57 AM
--> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
--> AppDomainName: 6485ed21-2-129491481241079508
--> WindowsIdentity: FTINDIA\ashwani.tiwari

 

 

 

 

at System.Data.SqlServerCe.SqlCeRestriction.CheckExplicitWebHosting()
   at System.Data.SqlServerCe.SqlCeConnection..ctor()
   at System.Data.SqlServerCe.SqlCeProviderFactory.CreateConnection()
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateConnection() in e:\Builds\EntLib\Latest\Source\Blocks\Data\Src\Data\Database.cs:line 334
   at Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.ExecuteStoredProcedure(LogEntry logEntry)
   at Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
   at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerWrapper.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\Logging\TraceListeners\TraceListenerWrapper.cs:line 92
   at Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\Logging\LogSource.cs:line 180
   at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl.ProcessLog(LogEntry log, TraceEventCache traceEventCache) in e:\Builds\EntLib\Latest\Source\Blocks\Logging\Src\Logging\LogWriterImpl.cs:line 557

Category:

Priority: -1

EventId: 6352

Severity: Error

Title:

Machine: ASHWANI

App Domain: 6485ed21-2-129491481241079508

ProcessId: 5384

Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE

Thread Name:

Win32 ThreadId:3676

Extended Properties:

May 6, 2011 at 11:06 AM

I'm suggesting you post your config here. I can't tell exactly by looking at the trace log.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 6, 2011 at 11:41 AM

<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="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, 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" />
  <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>
 <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
  <listeners>
   <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    source="Simple" formatter="Text Formatter" log="" machineName="."
    traceOutputOptions="None" />
   <add name="LoggingListener" 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="Logging" writeLogStoredProcName="WriteLog"
    addCategoryStoredProcName="AddCategory" formatter="Text Formatter" />
  </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="Event Log Listener" />
    </listeners>
   </add>
   <add switchValue="All" name="LoggingCategory">
    <listeners>
     <add name="LoggingListener" />
    </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="Event Log Listener" />
    </listeners>
   </errors>
  </specialSources>
 </loggingConfiguration>
 <exceptionHandling>
  <exceptionPolicies>
   <add name="ExceptionShielding">
    <exceptionTypes>
     <add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      postHandlingAction="None">
      <exceptionHandlers>
       <add name="LoggingHandler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        logCategory="General" eventId="100" severity="Error" title="ex"
        formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
        priority="0" />
      </exceptionHandlers>
     </add>
    </exceptionTypes>
   </add>
  </exceptionPolicies>
 </exceptionHandling>
 <dataConfiguration defaultDatabase="Tutorial" />
 <connectionStrings>
  <add name="Rusty" connectionString="***************"
   providerName="System.Data.SqlClient" />
  <add name="Ashwani" connectionString="**************"
   providerName="System.Data.SqlClient" />
  <add name="Tutorial" connectionString="***********************"
   providerName="System.Data.SqlClient" />
  <add name="Logging" connectionString="***********************"
   providerName="System.Data.SqlServerCe.3.5" />
 </connectionStrings>

May 6, 2011 at 12:00 PM

I just found out that your Database Trace Listener is pointing to the 'Logging' database instance on the Data Application Block which uses System.Data.SqlServerCe.3.5 as the database provider. If you will remember, the script you executed targets SQL server database so log won't work here as expected.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 6, 2011 at 12:11 PM

Thanks alot, Noel .

Jul 29, 2011 at 4:31 PM

Hi,

My requirement is - no log found in database tables. I changed database listener to Event Log Listener. I am able to see the error in Event Log, but couldnt find in database.

I have given below the web.config as well as Event Log.

Kindly help me to find out the reason asap.

EVENT LOG:

Event code: 3005

Event message: An unhandled exception has occurred.

Event time: 7/29/2011 8:16:11 PM

Event time (UTC): 7/29/2011 2:46:11 PM

Event ID: 59e8e9078bb64655b48ed92311abf331

Event sequence: 25

Event occurrence: 1

Event detail code: 0 

Application information:

   Application domain: /LM/w3svc/1/ROOT/ITSSMetricsDashboard-5-129564238801557408

   Trust level: Full

   Application Virtual Path: /ITSSMetricsDashboard

   Application Path: C:\Projects\Corporate ITSS Metrics Dashboard\Corporate ITSS Metrics Dashboard\ITSSMetricsDashboard\

   Machine name: SOPHIHOME 

Process information:

   Process ID: 3316

   Process name: w3wp.exe

   Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information:

   Exception type: HttpException

   Exception message: Response is not available in this context. 

Request information:

   Request URL:

   Request path:

   User host address:

   User:

   Is authenticated: False

   Authentication Type:

   Thread account name: NT AUTHORITY\NETWORK SERVICE

 

Thread information:

   Thread ID: 7

   Thread account name: NT AUTHORITY\NETWORK SERVICE

   Is impersonating: False

   Stack trace:   at System.Web.HttpApplication.get_Response()

   at ASP.global_asax.Session_End(Object sender, EventArgs e) in C:\Projects\Corporate ITSS Metrics Dashboard\Corporate ITSS Metrics Dashboard\ITSSMetricsDashboard\global.asax:line 47

 Custom event details: 

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

WEB.CONFIG:

<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
 <configSections>
  <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  <sectionGroup name="ajaxNet">
   <section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro.2" requirePermission="false" restartOnExternalChanges="true"/>
  </sectionGroup>
 </configSections>
 <cachingConfiguration defaultCacheManager="Cache Manager">
  <cacheManagers>
   <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Null Storage" name="Cache Manager"/>
  </cacheManagers>
  <backingStores>
   <add encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Null Storage"/>
  </backingStores>
 </cachingConfiguration>
 <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
  <listeners>
   <add databaseInstanceName="Exception Log" writeLogStoredProcName="usp_Log_Insert_Log" addCategoryStoredProcName="usp_Log_Add_Category" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Database Trace Listener"/>
   <add databaseInstanceName="Event Log" writeLogStoredProcName="usp_Log_Insert_Log" addCategoryStoredProcName="usp_Log_Add_Category" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Event Log Listener"/>
  </listeners>
  <formatters>
   <add template="Message: {message}&#xA;Category: {category}&#xA;Priority: {priority}&#xA;EventId: {eventid}&#xA;Severity: {severity}&#xA;Title:{title}&#xA;Machine: {machine}&#xA;Application Domain: {appDomain}&#xA;Process Id: {processId}&#xA;Process Name: {processName}&#xA;Win32 Thread Id: {win32ThreadId}&#xA;Thread Name: {threadName}&#xA;Extended Properties: {dictionary({key} - {value}&#xA;)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Text Formatter"/>
  </formatters>
  <categorySources>
   <add switchValue="All" name="Data Access Layer Exceptions">
    <listeners>
     <add name="Database Trace Listener"/>
    </listeners>
   </add>
   <add switchValue="All" name="Event">
    <listeners>
     <add name="Event Log Listener"/>
    </listeners>
   </add>
   <add switchValue="All" name="Web Service Access Layer Exceptions">
    <listeners>
     <add name="Database Trace Listener"/>
    </listeners>
   </add>
   <add switchValue="All" name="Web UI Layer Exception">
    <listeners>
     <add name="Database Trace Listener"/>
    </listeners>
   </add>
  </categorySources>
  <specialSources>
   <allEvents switchValue="All" name="All Events"/>
   <notProcessed switchValue="All" name="Unprocessed Category"/>
   <errors switchValue="All" name="Logging Errors &amp; Warnings"/>
  </specialSources>
 </loggingConfiguration>
 <exceptionHandling>
  <exceptionPolicies>
   <add name="Data Access Layer Policy">
    <exceptionTypes>
     <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="Exception">
      <exceptionHandlers>
       <add logCategory="Data Access Layer Exceptions" eventId="1000" severity="Error" title="Data Access Exception" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Logging Handler"/>
      </exceptionHandlers>
     </add>
    </exceptionTypes>
   </add>
   <add name="Web Service Access Layer Policy">
    <exceptionTypes>
     <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="Exception">
      <exceptionHandlers>
       <add logCategory="Web Service Access Layer Exceptions" eventId="3000" severity="Error" title="Web Service Exception" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Logging Handler"/>
      </exceptionHandlers>
     </add>
    </exceptionTypes>
   </add>
   <add name="Web UI Layer Policy">
    <exceptionTypes>
     <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="Exception">
      <exceptionHandlers>
       <add logCategory="Web UI Layer Exception" eventId="2000" severity="Error" title="Web UI Exception" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Logging Handler"/>
      </exceptionHandlers>
     </add>
    </exceptionTypes>
   </add>
  </exceptionPolicies>
 </exceptionHandling>
 <appSettings>
  <add key="ApplicationName" value="Corporate ITSS Metrics Dashboard"/>
  <add key="ExpiredTargetBufferMonths" value="2"/>
  <!--local="Development"-->
  <!--Dev="Development"-->
  <!--Test="Test"-->
  <!--Prod="Production"-->
  <add key="Security" value="Development"/>
    <add key="HardCodedNetworkID" value="naipaper\nramakr"/>
  <add key="SessionTimeOut" value="45"/>
  <add key="ApplicationVirtualName" value="ITSSMetricsDashboard"/>
  <add key="IsSSLEnabled" value="FALSE"/>
  <!--<add key="HardCodedNetworkID" value="naipaper\1f9RAD1"/>-->
 </appSettings>
 <connectionStrings>
  <add name="ITSS Metrics" connectionString="Database=db_ITSS_Metrics;Server=164.103.197.37;UID=radsqluser;Password=rads98*mi3;Connect Timeout=120;" providerName="System.Data.SqlClient"/>
  <add name="Audit Log" connectionString="Database=db_ITSS_Metrics;Server=s02asqld2;UID=radsqluser;Password=rads98*mi3;Connect Timeout=20;" providerName="System.Data.SqlClient"/>
  <add name="Event Log" connectionString="Database=db_ITSS_Metrics;Server=s02asqld2;UID=radsqluser;Password=rads98*mi3;Connect Timeout=20;" providerName="System.Data.SqlClient"/>
  <add name="Exception Log" connectionString="Database=db_ITSS_Metrics;Server=s02asqld2;UID=radsqluser;Password=rads98*mi3;Connect Timeout=20;" providerName="System.Data.SqlClient"/>
  <add name="NorthwindConnectionString" connectionString="Data Source=s02asqld2;Initial Catalog=Northwind;Persist Security Info=True;User ID=radsqluser;Password=rads98*mi3" providerName="System.Data.SqlClient"/>
  <add name="PubsConnectionString" connectionString="Data Source=s02asqld2;Initial Catalog=Pubs;Persist Security Info=True;User ID=radsqluser;Password=rads98*mi3" providerName="System.Data.SqlClient"/>
  <add name="db_MetricsConnectionString" connectionString="Database=db_ITSS_Metrics;Server=s02asqld2;UID=radsqluser;Password=rads98*mi3;Connect Timeout=120;" providerName="System.Data.SqlClient"/>
 </connectionStrings>
 <system.web>
  <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
  <!--<sessionState timeout="30" regenerateExpiredSessionId ="true" />-->
  <customErrors mode="Off" defaultRedirect="App_Common/Exception.aspx">
   <error statusCode="404" redirect="App_Common/404.aspx"/>
  </customErrors>
  <siteMap defaultProvider="Top_Nav_Full_Width_Secondard_Menu">
   <providers>
    <add name="Top_Nav_Full_Width_Secondard_Menu" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap"/>
   </providers>
  </siteMap>
  <compilation debug="true">
   <assemblies>
    <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
   </assemblies>
   <buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     <remove extension=".rdlc"/> <!-- Added to disallow rdlc file towards getting compiled -->
   </buildProviders>
  </compilation>
  <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
  <pages theme="ITSSMetricsTheme" styleSheetTheme="ITSSMetricsTheme" enableEventValidation="false">
   <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add tagPrefix="csla" namespace="Csla.Web" assembly="Csla"/>
    <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
    <add tagPrefix="rads" namespace="IP.RADS.Web.Controls.AjaxValidator" assembly="AjaxValidator"/>
    <add tagPrefix="ew" namespace="eWorld.UI" assembly="eWorld.UI"/>
   </controls>
   <namespaces>
    <clear/>
    <add namespace="System"/>
    <add namespace="System.Collections"/>
    <add namespace="System.Collections.Specialized"/>
    <add namespace="System.Configuration"/>
    <add namespace="System.Text"/>
    <add namespace="System.Text.RegularExpressions"/>
    <add namespace="System.Web"/>
    <add namespace="System.Web.Caching"/>
    <add namespace="System.Web.SessionState"/>
    <add namespace="System.Web.Security"/>
    <add namespace="System.Web.Profile"/>
    <add namespace="System.Web.UI"/>
    <add namespace="System.Web.UI.WebControls"/>
    <add namespace="System.Web.UI.WebControls.WebParts"/>
    <add namespace="System.Web.UI.HtmlControls"/>
   </namespaces>
  </pages>
  <authentication mode="Windows"/>
  <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
  <httpHandlers>
   <remove verb="*" path="*.asmx"/>
   <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   <add path="ajaxpro/*.ashx" verb="POST,GET" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
   <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
   <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" validate="false"/>
  </httpHandlers>
  <httpModules>
   <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </httpModules>
 </system.web>
 <system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
   <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </modules>
  <handlers>
   <remove name="WebServiceHandlerFactory-Integrated"/>
   <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </handlers>
 </system.webServer>
</configuration>

Aug 1, 2011 at 8:37 AM

I believe the logged error is not actually from Enterprise Library. I suspect that the error was not properly handled by Entlib (maybe because it is not configured to) and caught by the Event Log. The message below is a sample log of exception handled by Enterprise Library:

______________________________________________________________________________________________________

Log Name:      Application
Source:        Enterprise Library Logging
Date:          8/1/2011 3:11:42 PM
Event ID:      100
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      AvanadeSupport
Description:
Timestamp: 8/1/2011 7:11:42 AM

Message: HandlingInstanceID: 3a78c431-07ef-4fa0-9171-3c40b8d9a85b
An exception of type 'System.InvalidCastException' occurred and was caught.
---------------------------------------------------------------------------
08/01/2011 15:11:42
Type : System.InvalidCastException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Specified cast is not valid.
Source : ExceptionHandling
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void MyClassMethod()
Stack Trace :    at ExceptionHandling.Program.MyClass.MyClassMethod() in C:\EntLibPractices\ExceptionHandling\ExceptionHandling\Program.cs:line 50
   at ExceptionHandling.Program.<>c__DisplayClass2.<Main>b__1() in C:\EntLibPractices\ExceptionHandling\ExceptionHandling\Program.cs:line 22
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManagerImpl.Process(Action action, String policyName) in c:\EntLib\Entlib\Source\Blocks.Desktop\ExceptionHandling\Src\ExceptionHandling\ExceptionManagerImpl.cs:line 185

Additional Info:

MachineName : AvanadeSupport

TimeStamp : 8/1/2011 7:11:42 AM
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
AppDomainName : ExceptionHandling.vshost.exe
ThreadIdentity :
WindowsIdentity : AvanadeSupport\noel.a.c.bolasoc


Category: General

Priority: 0

EventId: 100

Severity: Error

Title:Enterprise Library Exception Handling

Machine: AvanadeSupport

App Domain: ExceptionHandling.vshost.exe

ProcessId: 7260

Process Name: C:\EntLibPractices\ExceptionHandling\ExceptionHandling\bin\Debug\ExceptionHandling.vshost.exe

Thread Name:

Win32 ThreadId:2264

Extended Properties:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Enterprise Library Logging" />
    <EventID Qualifiers="0">100</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2011-08-01T07:11:42.000000000Z" />
    <EventRecordID>65536</EventRecordID>
    <Channel>Application</Channel>
    <Computer>AvanadeSupport</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Timestamp: 8/1/2011 7:11:42 AM

______________________________________________________________________________________________________

Moving on, I saw that the error is actually originated from the global.asax. Have you implemented exception handling there?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

 

Aug 3, 2011 at 12:07 PM

Yes, Exception handling is handled in global.asax.

By seeing web.config, could u tell me, is something wrong in the enterprise library configuration?

If so, by modifyign the web.config, can I log the error in the mentioned db?

Kindly see the web.config in my previous post.

Thanks

Aug 3, 2011 at 2:39 PM

Your config looks fine. I  believe you are using Enterprise Library 2.0 here? I'm not sure if the issue is related to the version. Have you already identified the exact method where this "Response is not available in this context" exception? Can you post here that particular code?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Aug 4, 2011 at 8:10 AM

Hi Noel, Thanks for ur reply.

 I have given below the code and event log again. Kindly check it and let me know if something is wrong.

---------------------------------------------------------

Event code: 3005

Event message: An unhandled exception has occurred.

Event time: 8/3/2011 4:56:15 PM

Event time (UTC): 8/3/2011 11:26:15 AM

Event ID: 6c8d37f913b04032bf30415b7f164870

Event sequence: 26

Event occurrence: 1

Event detail code: 0 

Application information:

Application domain: /LM/w3svc/1/ROOT/ITSSMetricsDashboard-9-129568442857102590

Trust level: Full

Application Virtual Path: /ITSSMetricsDashboard

Application Path: C:\Projects\Corporate ITSS Metrics Dashboard\Corporate ITSS Metrics Dashboard\ITSSMetricsDashboard\

Machine name: W2KZ81X001

 

Process information:

Process ID: 720

Process name: aspnet_wp.exe

Account name: W2KZ81X001\ASPNET

 

Exception information:

Exception type: DataPortalException

Exception message: DataPortal.Update failed

 

Request information:

Request URL: http://localhost/ITSSMetricsDashboard/Metric Actual/EditAllMetricActuals.aspx

Request path: /ITSSMetricsDashboard/Metric Actual/EditAllMetricActuals.aspx

User host address: 127.0.0.1

User: naipaper\sramach

Is authenticated: True

Authentication Type: Csla

Thread account name: W2KZ81X001\ASPNET

 

Thread information:

Thread ID: 6

Thread account name: W2KZ81X001\ASPNET

Is impersonating: False

Stack trace: at Csla.DataPortal.Update(Object obj)

at Csla.DataPortal.Update[T](T obj)

at Csla.BusinessBase`1.Save()

at ITSSMetricsLibrary.ITSSMetrics.MetricActual.Save() in C:\Projects\Corporate ITSS Metrics Dashboard\Corporate ITSS Metrics Dashboard\ITSSMetricsLibrary\Metric Actual\MetricActual.vb:line 885

at Metric_Actual_EditAllMetricActuals.SaveActuals() in C:\Projects\Corporate ITSS Metrics Dashboard\Corporate ITSS Metrics Dashboard\ITSSMetricsDashboard\Metric Actual\EditAllMetricActuals.aspx.vb:line 187

at Metric_Actual_EditAllMetricActuals.btnSave_Click(Object sender, EventArgs e) in C:\Projects\Corporate ITSS Metrics Dashboard\Corporate ITSS Metrics Dashboard\ITSSMetricsDashboard\Metric Actual\EditAllMetricActuals.aspx.vb:line 527

at System.Web.UI.WebControls.Button.OnClick(EventArgs e)

at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)

at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

Custom event details:

For more information, see Help and Support Center at

 -------------------------------------------------------------------------

 

 

 

 

 

 

 

 

 

Private

 

Sub ExecuteUpdate(ByVal db As Database, ByVal dbCommand As

DbCommand)

 

Try

AddUpdateParameters(db, dbCommand)

db.ExecuteNonQuery(dbCommand)

dbCommand.Dispose()

 

Catch ex As

Exception

 

Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Data Access Layer Policy"

)

 

If (rethrow)

Then

 

Throw

 

End

If

 

End

Try

 

End

Sub

Aug 5, 2011 at 12:00 PM

Your application code looks fine. What is wrong, as far as I have noticed is that you actually don't have an Event Log trace listener.

Both tracelisteners you have is of type FormattedDatabaseTraceListenerData and just renamed as Event Log. I suggest checking them.

Hope this helps.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Jul 17, 2013 at 6:39 AM
HI i'm using Microsoft Enterprise library 5.0.

I store the Activity & Exception Log in database using database trace Listener.

i got following Error in database table in Message collumn.

Tracing to LogSource 'General' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.
__My web config file is:-__
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"
        databaseInstanceName="TestConnection" writeLogStoredProcName="WriteLog"
        addCategoryStoredProcName="General" formatter="Text Formatter"
        traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"
        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="Database Trace Listener" />
        </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="Database Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

my Connection String is:-


<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-CRUD-20130618172811;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-CRUD-20130618172811.mdf"
      providerName="System.Data.SqlClient" />
    <add name="TestConnection" connectionString="Data Source=servername;Initial Catalog=Logging;Integrated Security=true"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
how to solve ?
Jul 17, 2013 at 7:20 AM
See summary information below for more information
Is there any more information in the table? The exact error that occurred should be logged which should help pinpoint the exact issue. Also, you should change the errors special source to not use the Database Trace Listener and instead use another trace listener such as a flat file trace listener. This is because if writing the LogEntry to the database fails, it is quite possible that attempting to write the error information about why the write failed to the database again will also fail.

Also, just curious if you are using a custom built unsigned version of Enterprise Library (since the PublicKeyToken's are null)?

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jul 17, 2013 at 7:49 AM
Hi Randy..

Flat-file Trace Listener is Working Fine..Database trace listener only show the error ..

i refer this link:-

http://elijahm.ninjuro.com/2011/08/07/application-block-logging-enterprise-library-5-0/