Where does system.out.println in tomcat under windows gets written?

∥☆過路亽.° 提交于 2020-01-01 08:07:41

问题


I am using a third party library (cannot modify it) that uses for logging system.out.println statements. The output shows fine in the console but I am not able to retrieve those information in the catalina[...].log file?

Is it possible to send those to log4j?


回答1:


System.out.println() prints out to stdout. Therefore, if you want to see these statements in a log file, you can just redirect stdout where you want it in the Tomcat startup script.




回答2:


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).

http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Console




回答3:


If you are running a JSP then you need to add

 <%@ page isThreadSafe="false"  %>

Then all of your System.out.printlns will start showing up in the catalina.out file.

If you start tomcat with Catalina.sh run from a command line you will see the prints in the output.




回答4:


You can find those logs also in cat /var/log/messages

if you try

cat /var/log/messages | grep server



回答5:


You can find it inside TOMCAT_HOME/logs/stdout_20130104.txt (the file name may change but the log files are usually in the folder TOMCAT_HOME/logs/.

And for me all the sysouts that I have in my code are written in such a file.




回答6:


In my case (Fedora 29 apache-tomcat-8.5.39), it was found inside catalina.out file located inside logs folder.



来源:https://stackoverflow.com/questions/14158131/where-does-system-out-println-in-tomcat-under-windows-gets-written

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