Redirect Trace output to Console

后端 未结 3 749
萌比男神i
萌比男神i 2020-12-04 12:03

Let\'s say I\'m working on a little batch-processing console app in VB.Net. I want to be able to structure the app like this:



        
3条回答
  •  星月不相逢
    2020-12-04 12:27

    Great solution, but I have a situation where I have different dll's being run by the same calling exe, so I don't want to modify the calling exe's .config file. I want each dll to handle it's own alteration of the trace output.

    Easy enough:

    Stream outResultsFile = File.Create ("output.txt");
    var textListener = new TextWriterTraceListener (outResultsFile);
    Trace.Listeners.Add (textListener);
    

    This will, of course, output Trace output to the "output.txt" file.

提交回复
热议问题