XML TRACE LISTENER??

Topics: Logging Application Block
Apr 5, 2007 at 9:45 AM
Edited Apr 5, 2007 at 9:45 AM
Hi,

I see in FEB beta release of EntLib that there is a new trace listener called XML trace listener. I have been trying to use it to have xml output as a log instead of a flat file, but no luck so far. am i missing sth or is it not implemented yet?

Best Regards
Apr 5, 2007 at 9:21 PM
I just tried it and it looks good. Here is the output:

-<E2ETraceEvent>
-<System>
 <EventID>1</EventID>
 <Type>3</Type>
 <SubType Name="Information">0</SubType>
 <Level>8</Level>
 <TimeCreated SystemTime="2007-04-05T20:15:55.0781250Z"/>
 <Source Name="General"/>
 <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}"/>
 <Execution ProcessName="XMLTraceListener.vshost" ProcessID="1868" ThreadID="11"/>
 <Channel/>
 <Computer>Dev</Computer>
 </System>
-<ApplicationData>
-<TraceData>
-<DataItem>
-<LogEntry>
 <Message>Hello</Message>
-<Categories>
 <String>General</String>
 </Categories>
 <Priority>-1</Priority>
 <EventId>1</EventId>
 <Severity>Information</Severity>
 <LoggedSeverity>Information</LoggedSeverity>
 <Title/>
 <TimeStamp>4/5/2007 8:15:54 PM</TimeStamp>
 <MachineName>Dev</MachineName>
 <AppDomainName>XMLTraceListener.vshost.exe</AppDomainName>
 <ProcessId>1868</ProcessId>
 <ProcessName>C:\Examples2\Enterprise Library\Logging\XMLTraceListener\XMLTraceListener\bin\Debug\XMLTraceListener.vshost.exe</ProcessName>
 <ManagedThreadName/>
 <Win32ThreadId>3040</Win32ThreadId>
 <ExtendedProperties/>
 <TimeStampString>4/5/2007 8:15:54 PM</TimeStampString>
 <ActivityId>00000000-0000-0000-0000-000000000000</ActivityId>
 <RelatedActivityId/>
 <ErrorMessages/>
 <ActivityIdString>00000000-0000-0000-0000-000000000000</ActivityIdString>
-<CategoriesStrings>
 <String>General</String>
 </CategoriesStrings>
 </LogEntry>
 </DataItem>
 </TraceData>
 </ApplicationData>
 </E2ETraceEvent>

My configuration looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add fileName="trace-xml.log" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        name="XML Trace Listener" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="XML 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="XML Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
</configuration>

Regards,

Dave

________________________

David Hayden
Microsoft MVP C#