Oasis,
You shouldn't be using Console.WriteLine for ASP.NET applications.
Those messages are just going to be lost.
If you need to log certain things, you can attach listeners to the Trace
object (there are static methods to do this, and the class is in the
System.Diagnostics namespace). This will allow you to place messages in
your program to be written to the listeners. You can have the listeners
write output to a log file, a database, or whatever you wish. Additionally,
you can configure this without having to write any code (it would be
configured through the web.config file).
Take a look at the TraceListener class documentation for how configure
the trace listeners, as well as a list of pre-defined trace listeners.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Oasis said:
Speaking of logging,
Hello, I'm new to C#. I'm using Visual Studio and IIS, developing and
running web projects with C#. In this environment, when I execute
Console.writeln("Message");
the message does not appear in any window of my Vis. Studio that I know
of,
and does not log anywhere that I know of.
How can I configure IIS to log these Console.writelns to a specific place
and/or configure visual studio to write them to a console window?
Thanks for any help,
Andrew
Nicholas Paldino said:
Andy,
This is pretty much what other technologies do. For example, if an
exception is thrown on the server, then that exception is caught, and
then
placed in a RemotingException (the original exception is exposed through
the
InnerException property). This way, if there is a problem in the
remoting
itself, you can detect it through any exception except a
RemotingException.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Nicholas,
Thanks for the input.
Yes, I am definatly going to bubble up the exceptions. As each
exception is caught by a layer, it wraps it in an Exception declared in
that layer. (I believe this is what is commonly done as well, but I'd
appreciate comments on this practice as well).
Andy