Can I use System.Diagnostics.Trace as a registration form in Commons for .net?

I was wondering if there is a way that I could use the System.Diagnostics.Trace methods as a community registration form for my .Net libraries. Instead of including dependencies in these libraries for log4net or CommonsNet (which seems to be a similar logging project for java in .Net), can I use the built-in methods?

I see that you can add listeners to this trace output, but will there be performance penalties for the call Trace.TraceError, Trace.TraceWarningor Trace.TraceInformationfrom a critical performance code?

+3
source share
2 answers

, , , . app.config:

<configuration>
  <system.diagnostics>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
        <remove name="Default" />
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>

, , , . , Common.Logging, :

log.Trace(m=>m("value= {0}", obj.Value));

, LogLevel.Trace, . , .

+1

: "". ( ) TraceListener.

-, , , , .

0

All Articles