Where does system.out.println print from a JSP?

巧了我就是萌 提交于 2019-12-28 13:55:29

问题


Where does tomcat put the System.out.println output ?

I'm not interested in out.println. I'm using a system that uses system.out to log issues, like login success/fail, and I need to look to that generated "log".


回答1:


It usually prints to catalina.out.

It is highly unrecommended to log using system.out.println() from several reasons:

  • you cannot control which messages are logged and which aren't unless you change the code
  • catalina.out just grow all the time, and you cannot move it so that tomcat will create another one.

A better solution is to use one of the popular (and mature) logging frameworks:

  • java.util.logging (actually used by tomcat itself and you have no third party dependencies)
  • Log4j
  • Logback

A good solution which is backed by log4j, is to use Jakarta's log tag library, where you can have your logging messages in any of this forms

<log:info message="this is a message"/>

<log:info category="foo.bar" message="this is a message"/>

<log:info category="foo.bar">
  this is a message
</log:info>



回答2:


CATALINA_HOME/logs/stdout_YYYYMMDD.log

is the default, where CATALINA_HOME is your base Tomcat directory. There are various ways to change this programatically and via configuration.



来源:https://stackoverflow.com/questions/1543997/where-does-system-out-println-print-from-a-jsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!