简体   繁体   English

如何让servlet中的System.out.println显示在控制台上?

[英]How to get System.out.println in servlet to show on console?

I am running a simple servlet on Tomcat 7.0 in Windows. 我在Windows上的Tomcat 7.0上运行一个简单的servlet。

For the sake of debugging I want to 为了调试我想

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // do some stuff
    System.out.println("Some stuff was done");
    ...

    PrintWriter out = response.getWriter();
    out.println("Done");
}

However, I do not see my System.out.println output in either the console or any of the log files in the logs folder, be it catalina.log or catalina.out. 但是,我没有在控制台或日志文件夹中的任何日志文件中看到我的System.out.println输出,无论是catalina.log还是catalina.out。 I have searched this many times, but none of the methods I read work. 我已多次搜索过,但我读过的方法都没有。

All I need is for my output to show up on the console without having to use other utilities, so I'd really appreciate it if someone can show me the steps on how to fix it. 我需要的是我的输出显示在控制台上而不必使用其他实用程序,所以如果有人能告诉我如何修复它的步骤,我真的很感激。

For the sake of debugging, use some log framework like log4j . 为了调试,使用一些日志框架,如log4j

However, system.out logs will be in catalina.out or one of the localhost*.log files in your Tomcat's logs directory 但是,system.out日志将位于catalina.out或Tomcat日志目录中的localhost * .log文件之一

Is there a specific reason you're not using a logging framework or the standard Java logging? 您是否有特定原因未使用日志记录框架或标准Java日志记录? It's quite a bit more useful, and configurable. 它更有用,可配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM