java System.out 在 servlet 中写入的位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11986296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 07:10:06  来源:igfitidea点击:

Where System.out writes in a servlet?

javajspservletssystem.out

提问by vivek_jonam

I am just curious to know, what happens when System.out.print() is called in a servlet?
Where does it write the text?

我只是想知道,在 servlet 中调用 System.out.print() 时会发生什么?
它在哪里写文本?

Or is there any significant use of System.out in a servlet?

或者在 servlet 中是否有任何重要的 System.out 使用?

采纳答案by Jér?me Radix

It depends on your servlet container.

这取决于您的 servlet 容器。

For Tomcat:

对于Tomcat

When running Tomcat on unixes, the console output is usually redirected to the file named catalina.out. The name is configurable using an environment variable. (See the startup scripts). Whatever is written to System.err/out will be caught into that file.

在 unix 上运行 Tomcat 时,控制台输出通常重定向到名为 catalina.out 的文件。该名称可使用环境变量进行配置。(请参阅启动脚本)。写入 System.err/out 的任何内容都将被捕获到该文件中。

For jetty, you can redirect standard output to a file :

对于jetty,您可以将标准输出重定向到文件:

It is possible to redirect all output sent to stderr and stdout to a file that can be rolled over [...]

可以将发送到 stderr 和 stdout 的所有输出重定向到可以滚动的文件 [...]

回答by Pramod Kumar

System.out.print() writes on Server Console.

System.out.print() 写入Server Console.

回答by PrasoonMishra

It will write in the console .System.out is generally used in servlet to verify some piece of code is working,which we can refer in console.

它会写在控制台中。System.out一般在servlet中用来验证某段代码是否工作,我们可以在控制台中参考。

回答by JDGuide

No, there is any significant use of System.out in a servlet. Beacause , Servlet is a web technology for generating dynamic web pages. Normally , it returns response to HTMLpage. So, there is no need for print data on Console.

不,在servlet. 因为,Servlet 是一种用于生成动态网页的 Web 技术。通常,它返回对HTML页面的响应。因此,不需要在 上打印数据Console

For Console print, there are many other options except Servlet. But still if we want to print data on console then you can write inside service(),doGet(),doPost()and other methods also :-

对于控制台打印,除了Servlet. 但是如果我们想在控制台上打印数据,那么你也可以在里面写service(),doGet(),doPost()和其他方法:-

System.out.println("YOUR MESSAGE");

But, it is recommended to avoid that.

但是,建议避免这种情况。