从JSP在哪里打印system.out.println? [英] Where does system.out.println print from a JSP?
问题描述
tomcat将System.out.println
输出放在哪里?
Where does tomcat put the System.out.println
output ?
我对out.println
不感兴趣.我使用的系统使用system.out
记录问题,例如登录成功/失败,并且我需要查看生成的日志".
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".
推荐答案
通常打印到catalina.out.
It usually prints to catalina.out.
强烈建议不要使用system.out.println()进行日志记录,原因如下:
It is highly unrecommended to log using system.out.println() from several reasons:
- 除非更改代码,否则您无法控制记录哪些消息,哪些消息不记录
- catalina.out一直在增长,并且您无法移动它,因此tomcat将创建另一个.
更好的解决方案是使用一种流行的(成熟的)日志记录框架:
A better solution is to use one of the popular (and mature) logging frameworks:
- java.util.logging (实际上是tomcat本身使用的,并且您没有第三方依赖项)
- Log4j
- 登录
- java.util.logging (actually used by tomcat itself and you have no third party dependencies)
- Log4j
- Logback
由log4j支持的一个很好的解决方案是使用Jakarta的日志标签库,您可以在其中以任何这种形式保存日志消息
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>
这篇关于从JSP在哪里打印system.out.println?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!