哪里Console.WriteLine在ASP.net生产环境去? [英] Where does Console.WriteLine go in ASP.net production enviroment?

查看:131
本文介绍了哪里Console.WriteLine在ASP.net生产环境去?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何机会,我可以在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)

我查了一下这个问题:

哪里Console.WriteLine进去ASP.NET?

但问题是,他们都在谈论它的Visual Studio的输出窗口可以用来检查这些线路的输出调试/开发环境。

But the problem is that they all talk about debugging/development environment which output window of Visual Studio can be used to check the output of those lines.

是否真的有方法来查看这些线路的输出,而无需安装额外的日志记录工具(如log4net的)?

Is there really a way to view the output of those lines without installing extra logging tools (e.g. log4net)?

推荐答案

Console.WriteLine(默认情况下重定向到Console.Out.WrlteLine)写入的 Stream.Null ,意思是写的东西给他们丢失,按照该<一个href=\"http://stackoverflow.com/questions/137660/where-does-console-writeline-go-in-asp-net\">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.

要重定向 Console.Out 到另一个流,这样的文件,使用 Console.SetOut ,如在Global.asax文件中的BeginRequest处理器。这将重定向任何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应用程序或通用库这个原因。请考虑使用一个日志库,如 log4net的

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生产环境去?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆