Generate a LOGGING file using System.Diagnostics. C #

1

I am trying to generate a .log file using System.Diagnostics in a console project.

The problem is that the .log file that I generate, returns it to me empty.

Here is the code I used in .NET :

TraceSource tr = new TraceSource("Wall-E", SourceLevels.All);
                tr.TraceEvent(TraceEventType.Information, 1,
                    "Error message.");

And here I leave the configuration that I used in the app.config of the project:

<configuration>
  <system.diagnostics>
    <sources>
      <source name="Wall-E">
        <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="Wall-E.log" />

          <add name="xmlfileListener"
               type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="Wall-E.xml" />

          <add name="defaultListener"
               type="System.Diagnostics.DefaultTraceListener"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

Greetings

    
asked by Nahuel Picca 20.10.2017 в 17:27
source

0 answers