哪里Console.WriteLine在ASP.NET中去? [英] Where does Console.WriteLine go in ASP.NET?
问题描述
在J2EE应用程序(在WebSphere像一个运行),当我使用的System.out.println()
,我的文字去到标准输出,它被映射到通过WebSphere管理控制台的文件。
In a J2EE application (like one running in WebSphere), when I use System.out.println()
, my text goes to standard out, which is mapped to a file by the WebSphere admin console.
在ASP.NET应用程序(在IIS像一个运行),其中的确的输出Console.WriteLine()
去了? IIS进程必须具有标准输入,输出和错误;但标准输出映射到Windows版本的/ dev / null的,或者我在这里缺少一个关键的概念?
In an ASP.NET application (like one running in IIS), where does the output of Console.WriteLine()
go? The IIS process must have a stdin, stdout and stderr; but is stdout mapped to the Windows version of /dev/null or am I missing a key concept here?
我的不要求如果我应该记录有(我用log4net的),但哪里输出去了?我最好的信息从这个<少时href=\"http://www.velocityreviews.com/forums/t91075-where-does-consolewriteline-goto.html\">discussion在那里,他们说 Console.SetOut()
可修改的TextWriter
,但它仍然没有回答的问题是什么控制台的初始值,或者如何设置它在运行时code的配置/之外。
I'm not asking if I should log there (I use log4net), but where does the output go? My best info came from this discussion where they say Console.SetOut()
can change the TextWriter
, but it still didn't answer the question on what the initial value of the Console is, or how to set it in config/outside of runtime code.
推荐答案
如果你看一下的控制台类://en.wikipedia .ORG /维基/ .NET_Reflector>。NET的反射,你会发现,如果一个进程没有关联的控制台, Console.Out
和 Console.Error
按 Stream.Null
进行备份(裹在的TextWriter
),这是一个虚拟的实施流
,基本上忽略所有输入,并给出了无输出。
If you look at the Console
class in .NET Reflector, you'll find that if a process doesn't have an associated console, Console.Out
and Console.Error
are backed by Stream.Null
(wrapped inside a TextWriter
), which is a dummy implementation of Stream
that basically ignores all input, and gives no output.
因此,在概念上等同于的/ dev / null的
,但实现更精简:有没有实际的I / O正与空设备
So it is conceptually equivalent to /dev/null
, but the implementation is more streamlined: there's no actual I/O taking place with the null device.
此外,除了呼吁放样
,有没有办法配置默认。
Also, apart from calling SetOut
, there is no way to configure the default.
这篇关于哪里Console.WriteLine在ASP.NET中去?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!