4

This is how trace listener defined in app.config:

  <system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="Listener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Import.log" traceOutputOptions="None" />
        <remove name="Default" />
      </listeners>
    </trace>
  </system.diagnostics>

And the simple method that calls Trace.WriteLine:

  public static void WriteLine(LogLevel logLevel, string message)
  {
       var message = String.Format("{0}", messageText);

       Trace.WriteLine(message);   
  }

But as a result - there is no file created and messages there. I thought that the reason could be in method that is calling outside of assembly. But that looks impossible. Is there any additional settings that I missed? Thanks in advance.

2
  • Has application privileges for write to that path? May 22, 2014 at 11:27
  • Yes, it's regular folder.
    – vmeln
    May 22, 2014 at 11:28

1 Answer 1

1

Actually the problem was in that the static method with logging was invoking from another assembly. There are two solutions I've figured out:

  • Make app.config copying after build (or copy manually) to the folder with assembly which contains that method;
  • Declare diagnostics section with trace options in app.config of executing assembly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.