Reputation: 219
I have generated a xml trace for my program using the Enterprise Library TraceManager. It works great. Using the Microsoft Service Trace Viewer, I can see a separate trace per call.
I would love to query the file so I found Microsoft Logparser and was hopeful I could use that. Unfortunately, I cannot figure out the expected input format. Input of XML returns a error of more than one root node found for the document. None of the other format parse the correct number of line.
Has anyone had any success querying a SVCLog File
TraceManager traceManager
traceManager = EnterpriseLibraryContainer.Current.GetInstance<TraceManager>();
TraceLogEntry traceEntry = new TraceLogEntry();
using (this.traceManager.StartTrace("Tracing")){
traceEntry.Title = "Message";
traceEntry.Priority = Priority;
this.traceManager.LogWriter.Write(traceEntry);
}
The Tracing Category is hooked up to a XML trace listener:
< loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
< listeners>
< add name="XML Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="c:\A2ISOtrace.svclog" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId" />
< /listeners>
< categorySources>
< add switchValue="All" name="Tracing">
< listeners>
< add name="XML Trace Listener" />
< /listeners>
< /add>
< /categorySources>
Log produces a number of rows like:
< E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System <EventID>1</EventID><Type>3</Type>. . . .
Upvotes: 3
Views: 1972
Reputation: 18082
Since your SVCLog file is missing a root element you could embed it into a basic Xml document.
The Xml document
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE Root SYSTEM "Test.dtd">
<Root>
&svclog;
</Root>
The DTD document
<!ENTITY svclog SYSTEM "SVCLog.xml">
where you declare the ENTITY
svclog importing your SVCLog file.
Now you should be able to parse the Xml input.
Upvotes: 2