System.Diagnostics.Trace.WriteLine("Second's destructor is called.");
using System.Diagnostics;
System.Diagnostics.Trace.WriteLine("Second's destructor is called.");
TraceSource ts = new TraceSource("HelloWorld", SourceLevels.All);
ts.TraceInformation("# of records processed: {0}", n);
ts.TraceEvent(TraceEventType.Information, 10, "# of records processed: {0}", n);
ts = new TraceSource("HelloWorld", SourceLevels.Critical | SourceLevels.ActivityTracing);
<system.diagnostics>
<sources>
<source name="HelloWorld">
<listeners>
<remove name="Default"/>
<add name="consoleListener"
type="System.Diagnostics.ConsoleTraceListener"/>
<add name="eventlogListener"
type="System.Diagnostics.EventLogTraceListener"
initializeData="Application"/>
<add name="textfileListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="helloworld.log" />
<add name="xmlfileListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="helloworld.xml" />
<add name="defaultListener"
type="System.Diagnostics.DefaultTraceListener"/>
</listeners>
</source>
</sources>
</system.diagnostics>
<system.diagnostics>
<sharedListeners>
<add name="myListener"
type="MyTestTraceListener, MyAssembly">
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Information"/>
</add>
</sharedListeners>
<sources>
<source name="mySource" switchValue="All">
<listeners>
<add name="myListener" />
</listeners>
</source>
</sources>
</system.diagnostics>
log.Info( m=>m("some logger info {0}", (object)myObj) )
log.Info( ()=>String.Format("some logger info {0}", (object)myObj) )
Hiç yorum yok:
Yorum Gönder