问题描述
是否有任何机会,我可以在IIS部署我的asp.net web应用程序之后,会Console.WriteLine命令的输出? (没有更多的Visual Studio)
Is there any chance that I can see the output of Console.WriteLine command after deploying my asp.net web application in IIS? (no more Visual Studio)
我查了一下这个问题:
,意思是写的东西给他们丢失,按照该question你提到。
Console.WriteLine (which redirects to Console.Out.WrlteLine by default) is written to Stream.Null, meaning things written to them are lost, as per the question you mention.
要重定向到另一个流,这样的文件,使用,如在Global.asax文件中的。这将重定向任何Console.WriteLine调用输出文件。还记得在EndRequest处理程序或类似的位置,以关闭流。
To redirect Console.Out to another stream, such as a file, use Console.SetOut, such as in the global.asax file BeginRequest handler. This will redirect any Console.WriteLine calls to the output file. Remember to close the stream in the EndRequest handler or similar location.
正如其他人在这里说,Console.WriteLine一般应避免在Web应用程序或通用库这个原因。请考虑使用一个日志库,如。
As others have said here, Console.WriteLine should be generally avoided in a web application or general purpose libraries for this reason. Consider using a logging library, such as log4net.
这篇关于哪里Console.WriteLine在ASP.net生产环境去?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!