[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

How to add extra columns to MS Exception/Logging Block

I am using the Microsoft Exception Handling and Logger Blocks. Right now, the Exception Block is writing to the database because of this setting in the web.config below.
 
This will write to the database out of the box. Does anyone know how to add extra columns and make the logger populate those new columns?
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
  defaultCategory="SomeError" logWarningsWhenNoCategoriesMatch="true">
  <listeners>
    <add databaseInstanceName="DevLogging" writeLogStoredProcName="WriteLog"
      addCategoryStoredProcName="AddCategory" formatter="ErrorFormatter"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
      traceOutputOptions="DateTime" 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" />
  </listeners>
  <formatters>
    <add template="Timestamp: {timestamp}&#xA;&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;&#xA;Severity: {severity} &#xD;&#xA;&#xA;Title: {title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;&#xA;Application Domain: {appDomain}; &#xA;Process Id: {processId}; &#xA;Process Name: {processName};&#xD;&#xA;Win32 Thread Id: {win32ThreadId}; &#xA;Thread Name: {threadName}&#xA; &#xD;&#xA;&#xD;&#xA;EXTENDED PROPERTIES: &#xD;&#xA;---------------------&#xD;&#xA;{dictionary({key} = {value} | )}&#xD;&#xA;"
      type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
      name="ErrorFormatter" />
  </formatters>
  <categorySources>
    <add switchValue="All" name="SomeError">
      <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>
...
  <exceptionHandling>
    <exceptionPolicies>
         <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow" name="Exception">
            <exceptionHandlers>
              <add logCategory="SomeError" eventId="100" severity="Error"
                title="Some Policy" 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>
    </exceptionPolicies>
  </exceptionHandling>

Open in new window

0
bemara57
Asked:
bemara57
1 Solution
 
tillgeffkenCommented:
You should probably create a custom trace listener as described in http://msdn.microsoft.com/en-us/library/cc309289.aspx

Although you would probably want to inherit a FormattedDatabaseTraceListener
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now