Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending output to stdout (console) in a VB.NET win form project

Tags:

vb.net

stdout

I have an application with a String variable that repeated gets a Date from a database, does something with that field, then goes onto the next row.

Is there a way I can send send out some debugging information to the stdout console so I can debug better/view the progress of the program?


2 Answers

You can use Debug.WriteLine.

You can configure your application to use the ConsoleTraceListener:

To direct all trace and debug messages to the console while the application executes, add a ConsoleTraceListener object to the application configuration file. Edit the configuration file that corresponds to the name of your application, or the app.config file in a Visual Studio 2005 project. In this file, insert an element for a ConsoleTraceListener.

The following example adds a ConsoleTraceListener object named configConsoleListener to the Listeners collection.

<configuration>
  <system.diagnostics>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="configConsoleListener" 
          type="System.Diagnostics.ConsoleTraceListener" />
      </listeners>
    </trace>
  </system.diagnostics>
 </configuration>

Then you can call Debug.WriteLine and it will log to the output console.

like image 137
Andrew Hare Avatar answered Nov 28 '25 17:11

Andrew Hare


System.Console.WriteLine will also do the trick.

Documentation

like image 29
Adam Avatar answered Nov 28 '25 17:11

Adam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!