473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

System.Console.WriteLine question

Hi Newsgroupies,

I'm writing a Web Forms program using C# (VS.NET 2003) and trying to
monitor it whilst running using "System.Console.WriteLine(<params>)" but
can't for the life of me find where it outputs too.

Am I thick or just unlucky?

Please help!

Lost & Bewildered, UK

Ps: Back in the good old days we had something called "TRACE" ;-)
Nov 16 '05 #1
12 3759
Unfortunately I don't think you can use Console. Apparently standard input
and standard output are not mapped to the console for an ASP.NET
application. I would suggest opening a file and writing to the file for
logging purposes. I ran into this issue some time ago. You are not missing
anything.

Thomas P. Skinner [MVP]

"newsgroupie" <ne*********@nospam.com> wrote in message
news:QR**************@rjmeltd.demon.co.uk...
Hi Newsgroupies,

I'm writing a Web Forms program using C# (VS.NET 2003) and trying to
monitor it whilst running using "System.Console.WriteLine(<params>)" but
can't for the life of me find where it outputs too.

Am I thick or just unlucky?

Please help!

Lost & Bewildered, UK

Ps: Back in the good old days we had something called "TRACE" ;-)

Nov 16 '05 #2
Thomas P. Skinner [MVP] wrote:
Unfortunately I don't think you can use Console. Apparently standard input
and standard output are not mapped to the console for an ASP.NET
application. I would suggest opening a file and writing to the file for
logging purposes. I ran into this issue some time ago. You are not missing
anything.

Ps: Back in the good old days we had something called "TRACE" ;-)


Couldent you just use System.Diagnostics.Debug.WriteLine for this?
Nov 16 '05 #3
Yes. This works as long as you run the application under VS.NET under debug
mode. The output from Debug.WriteLine calls goes to the output window. I was
thinking the question was geared more to a type of logging/monitoring rather
than debugging.

I often change the build to a console build for a Windows Forms application
for just such a purpose. When you do that you get a console window that you
can use Console.WriteLine to output to. This works regardless of whether you
run the program from VS.NET or not.

Thomas P. Skinner [MVP]

"Benjamin" <cs************@spamgourmet.com> wrote in message
news:u2**************@tk2msftngp13.phx.gbl...
Thomas P. Skinner [MVP] wrote:
Unfortunately I don't think you can use Console. Apparently standard
input and standard output are not mapped to the console for an ASP.NET
application. I would suggest opening a file and writing to the file for
logging purposes. I ran into this issue some time ago. You are not
missing anything.

Ps: Back in the good old days we had something called "TRACE" ;-)


Couldent you just use System.Diagnostics.Debug.WriteLine for this?

Nov 16 '05 #4
There are various tools out there that let you look at the debug output
stream without having to attach a debugger. Here's one:

http://www.sysinternals.com/ntw2k/fr...ebugview.shtml

But if you want to do logging, then look at the Trace class. Or if you want
a lot of flexibility, consider looking at the log4net project.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

"Thomas P. Skinner [MVP]" wrote:
Yes. This works as long as you run the application under VS.NET under
debug mode. The output from Debug.WriteLine calls goes to the output
window. I was thinking the question was geared more to a type of
logging/monitoring rather than debugging.

I often change the build to a console build for a Windows Forms
application for just such a purpose. When you do that you get a console
window that you can use Console.WriteLine to output to. This works
regardless of whether you run the program from VS.NET or not.

Thomas P. Skinner [MVP]

"Benjamin" <cs************@spamgourmet.com> wrote in message
news:u2**************@tk2msftngp13.phx.gbl...
Thomas P. Skinner [MVP] wrote:
Unfortunately I don't think you can use Console. Apparently standard
input and standard output are not mapped to the console for an ASP.NET
application. I would suggest opening a file and writing to the file for
logging purposes. I ran into this issue some time ago. You are not
missing anything.

Ps: Back in the good old days we had something called "TRACE" ;-)


Couldent you just use System.Diagnostics.Debug.WriteLine for this?

Nov 16 '05 #5
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

....And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.

Many thanks in advance,

newsgroupie
Nov 16 '05 #6
newsgroupie <ne*********@nospam.com> wrote:
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

...And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.


So call String.Format yourself:

String.Format ("The function returned {0}", returnValue);

and pass that in as the single argument.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

....And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.

Many thanks in advance,

newsgroupie
Nov 16 '05 #8
newsgroupie <ne*********@nospam.com> wrote:
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

...And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.


So call String.Format yourself:

String.Format ("The function returned {0}", returnValue);

and pass that in as the single argument.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #9
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

....i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnostics.Trace.WriteLine( String.Format( "{0}",
iNumber.ToString() ) );

Thanks again,

Newsgroupie

In message <MP************************@msnews.microsoft.com >, Jon Skeet
<?@pobox.com.invalid> writes
newsgroupie <ne*********@nospam.com> wrote:
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

...And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.


So call String.Format yourself:

String.Format ("The function returned {0}", returnValue);

and pass that in as the single argument.

Nov 16 '05 #10
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

....i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnostics.Trace.WriteLine( String.Format( "{0}",
iNumber.ToString() ) );

Thanks again,

Newsgroupie

In message <MP************************@msnews.microsoft.com >, Jon Skeet
<?@pobox.com.invalid> writes
newsgroupie <ne*********@nospam.com> wrote:
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

...And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.


So call String.Format yourself:

String.Format ("The function returned {0}", returnValue);

and pass that in as the single argument.

Nov 16 '05 #11
newsgroupie <ne*********@nospam.com> wrote:
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

...i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnostics.Trace.WriteLine( String.Format( "{0}",
iNumber.ToString() ) );


Use String.Format ("{0:d4}", iNumber)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #12
newsgroupie <ne*********@nospam.com> wrote:
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

...i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnostics.Trace.WriteLine( String.Format( "{0}",
iNumber.ToString() ) );


Use String.Format ("{0:d4}", iNumber)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Abraham Lopez | last post by:
Hi.. Is there a way to convert a System.Array to XML... If you know thanks very much... if you don't... Please do not respond stupid things like " Yes -- many ways."
1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
4
by: William McIlroy | last post by:
Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement.. using...
9
by: Tylius | last post by:
This one line is causing the issue, I've searched all over the net, but I can't seem to figure out why public static void Main(string args) { Console.WriteLine("Dice Roller"); try { int...
5
by: Deiussum | last post by:
I'm running into an issue where I have a timer that appears to be timing out immediately, when it shouldn't be timing out for about int.MaxValue milliseconds. I have written a small app that...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
20
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool...
1
by: =?Utf-8?B?QnJpYW4gQ29iYg==?= | last post by:
This code is contained in one source file in VS 2005 project: using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace ReflectionTest {...
1
by: nygiantswin2005 | last post by:
Hi I am trying to resolve this bug that I have in this application. The code is below. It will generate this Exception System.UnauthorizedAccessException: Access to the path is denied. at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.