Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

No log entry in database -enterprise library 6.0

$
0
0
i am trying to log exceptions to database but by using logging,database block only.

The structure is ,database=DLAdmin,Table=ExceptionLog.

I modified the LoggingDatabase.sql file by
  1. adding use "use [DLAdmin]" and eliminating create database.
  2. i also change table Log to ExceptionLog.
I ran the sql in sql studio.

the config file is
<?xml version="1.0" encoding="utf-8"?><configuration><configSections>    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/></configSections><appSettings><add key="ServerName" value="DELL-PC\SQLEXPRESS"/><!-- User token for API server access, required --><add key="DataBaseName" value="DLAdmin"/></appSettings><startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup><loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General">    <listeners>      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Database Trace Listener" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" formatter="Text Formatter" databaseInstanceName="Logging" writeLogStoredProcName="WriteLog"  addCategoryStoredProcName="AddCategory">   </add></listeners>    <formatters>   <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter" template="Timestamp: {timestamp}{newline} Message: {message}{newline} Category: {category}{newline} Priority: {priority}{newline} EventId: {eventid}{newline} Severity: {severity}{newline} Title:{title}{newline} Machine: {localMachine}{newline} App Domain: {localAppDomain}{newline} ProcessId: {localProcessId}{newline} Process Name: {localProcessName}{newline} Thread Name: {threadName}{newline} Win32 ThreadId:{win32ThreadId}{newline} Extended Properties: {dictionary({key} - {value}{newline})}">   </add></formatters><categorySources>   <add name="General" switchValue="All">         <listeners>       <add name="Database Trace Listener"></add></listeners></add> </categorySources>   <specialSources>    <allEvents switchValue="All" name="All Events"/><notProcessed switchValue="All" name="Unprocessed Category"><listeners><add name="Database Trace Listener"/></listeners></notProcessed><errors switchValue="Information" name="Logging Errors &amp; Warnings"><listeners><add name="Database Trace Listener"/></listeners></errors></specialSources></loggingConfiguration> <connectionStrings>  <add name="Logging" providerName="System.Data.SqlClient" connectionString="Data Source=DELL3-PC\SQLEXPRESS;Initial Catalog=DLAdmin" /></connectionStrings></configuration>

The c# code in app.xaml.cs is
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(new     SystemConfigurationSource(true).GetSection));
  LogWriterFactory logWriterFactory = new LogWriterFactory();

  logger=logWriterFactory.Create(); 

Then I call the following code from catch blocks
LogEntry le = new LogEntry();
            le.Severity =evttype;
            le.Message = strmsg;
            le.Priority = priority;
            try
            {

                App.logger.Write(entry);
            }

The code is executing.but no entry is found in the exceptionlog table. I thought I have done everything I found in the reference samples

what am I missing here?


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>