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

后端 未结 2 1904
栀梦
栀梦 2020-12-09 21:12

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

2条回答
  •  眼角桃花
    2020-12-09 21:46

    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

    
    
    
    
    
      this is a message
    
    

提交回复
热议问题