473,802 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(<par ams>)" 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 3790
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]

"newsgroupi e" <ne*********@no spam.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(<par ams>)" 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.Diagnost ics.Debug.Write Line 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.WriteLi ne to output to. This works regardless of whether you
run the program from VS.NET or not.

Thomas P. Skinner [MVP]

"Benjamin" <cs************ @spamgourmet.co m> wrote in message
news:u2******** ******@tk2msftn gp13.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.Diagnost ics.Debug.Write Line 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.WriteLi ne to output to. This works
regardless of whether you run the program from VS.NET or not.

Thomas P. Skinner [MVP]

"Benjamin" <cs************ @spamgourmet.co m> wrote in message
news:u2******** ******@tk2msftn gp13.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.Diagnost ics.Debug.Write Line 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*********@no spam.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.co m>
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*********@no spam.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.co m>
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.Diagnost ics.Trace.Write Line( String.Format( "{0}",
iNumber.ToStrin g() ) );

Thanks again,

Newsgroupie

In message <MP************ ************@ms news.microsoft. com>, Jon Skeet
<?@pobox.com.in valid> writes
newsgroupie <ne*********@no spam.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.Forma t ("The function returned {0}", returnValue);

and pass that in as the single argument.

Nov 16 '05 #10

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

Similar topics

5
12051
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
17140
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 characters like &#x1;. Using the CreateTextNode method I create a text node containing "\u0001a" (C# string literal notation). As far as I understand the DOM allows that and an implementation is not required to throw an error. When OuterXml is...
4
3856
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 System using System.Xml using System.Collections // This program reads an ASCII file of XML elements // The output is a list of unique NODE TYPEs // For example, <head> produces head in the output // There is no validation of the XML
9
16564
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 num_dice = int.Parse(args); // This is the problem
5
6598
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 isolates the problem and was wondering if anyone had any ideas on what I am doing wrong, or if there is some known bug, or I am exceeding some known maximum (which I can't seen to find in documentation anywhere...) Anyway, the following code used to...
6
10220
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 message: "The process cannot access the file "whatever" because it is being used by another process." I've even tried opening another file using the same streamwriter object before deleting the original file, but it's no use. Something keeps...
20
1487
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 threads - only happens when built with the 'release' configuration (no debug flag, compiler optimizations in effect) - no problems in debug config here is the error: Unhandled Exception: System.AccessViolationException: Attempted to read or write...
1
2444
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 { internal class x
1
4606
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 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.__Error.WinIOError() at System.IO.FileInfo.MoveTo(String destFileName)
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.