Pregunta

I'm using system.diagnostic to log all the errors to a log file

Web.Config:

<system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="MyListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="MyListenerLog.txt" />
        <remove name="Default" />
      </listeners>
    </trace>

  </system.diagnostics>

Code:

 private static void AddToMyListner(string message)
        {
            try
            {
                System.Diagnostics.Trace.WriteLine("Text: " +message + "," + DateTime.UtcNow);
                System.Diagnostics.Trace.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

In the Log file the first log i got was

no configuration section <common/logging> found - suppressing logging output

This log is printed only once i.e. only when I create a new log file. I'm not using Common.Logging so i was wondering what is causing this issue.

¿Fue útil?

Solución

Common.Logging is commonly integrated with tracing. If you're getting this error and you're not deliberately referencing Common.Logging then you're probably referencing some external library that uses Common.Logging and subscribes to the trace by default. If there's no configuration in place (reasonable, since you're not intending to use Common.Logging) then this would happen when Common.Logging receives a notification that something was written to the trace and doesn't know what to do about it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top